All the widgets shown on user's dashboard in front end, are nothing but the plugins of 'tjlmsdashboard' type.
You can refer any of the plugins placed in YOUR_SITE/plugins/tjlmsdashbord.
Here are the steps to be followed to create an widget to be shown of shika dashboard in frontend :
1. Create a plugin of type tjlmsdashboard. (Suppose plugin is custom widget)
This plugin will have follwowing files/folders
- customwidget.php (file)
- customwidget.xml (file)
- customwidget(folder)
- tmpl( folder)
- default.php(file)
2. In the customwidget.php following function is mandatory.
public function customwidgetRenderPluginHTML($plg_data, $layout = 'default') { /*The Function name is derived as PLUGIN_NAME . RenderPluginHTML*/ /* The $plg_data is an object, and for now it contains a property user_id having value of logged in user id. */ /* The $layout is an string having value as default, */ /*Here you will write some code, to get the data that wil be useful to generate the customwidger blog*/ $userCourseData = $this->getData($plg_data); /*Now you have all the required data in $userCourseData and now you have to pass it to a template layout where the html is written*/ // Load the layout & push variables ob_start(); $layout = $this->buildLayoutPath($layout); include $layout; $html = ob_get_contents(); ob_end_clean(); return $html; }
/** * This function will load the layout file from tmpl folder. But if the file is overriden, it will load it from template. * * @param ARRAY $layout Layout to be used * * @return File path * * @since 1.0.0 */ protected function buildLayoutPath($layout) { if (empty($layout)) { $layout = "default"; } $app = JFactory::getApplication(); $core_file = dirname(__FILE__) . '/' . $this->_name . '/' . 'tmpl' . '/' . $layout . '.php'; $override = JPATH_BASE . '/templates/' . $app->getTemplate() . '/html/plugins/' . $this->_type . '/' . $this->_name . '/' . $layout . '.php'; if (JFile::exists($override)) { return $override; } else { return $core_file; } }