Developing dashlets

From KnowledgeTree Community

Jump to: navigation, search

A dashlet is a section that is displayed on the dashboard page, usually displayed after a user logs on.

A dashlet generally extends from the KTBaseDashlet class:

require_once(KT_LIB_DIR . '/dashboard/dashlet.inc.php');
class KTBeta1InfoDashlet extends KTBaseDashlet {
...
}

A dashlet need only implement a single method, render, which should return (not output) the contents it wishes to place within a dashlet on the dashboard page:

    function render() {
        $oTemplating = new KTTemplating;
        $oTemplate = $oTemplating->loadTemplate("ktcore/dashlets/beta1info");
        $aTemplateData = array(
        );
        return $oTemplate->render($aTemplateData);
    }

Since 3.3.0, dashlets have the following attributes:

  • $sTitle
  • $sClass

All dashlets now have a title, which should be set in the dashlet's constructor. Prior to 3.3.0, the title needed to be included in the dashlet's template code.

The $sClass property can be set to either:

  • ktBlock (the default)
  • ktError renders the dashlet in a 'yellow' highlighted state
  • ktInfo

class KTBeta1InfoDashlet extends KTBaseDashlet {
  var $sClass='ktError';

 function KTBeta1InfoDashlet()
 {
  $this->sTitle='Beta1Info';
 }
}
Personal tools