Add new menu and view by a plugin: Difference between revisions
From LimeSurvey Manual
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
== Add new content in side-body in LimeSurvey 2.5 == | == Add new content in side-body in LimeSurvey 2.5 == | ||
A plugin can add content into the side-body div in the LimeSurvey 2.5 admin interface by calling the <code>PluginHelper</code> controller. As in the section above, you will need to add a new menu with an acnhor to the controller, which will in turn call your plugin action. The return value of the plugin action will be rendered in the side-body. | A plugin can add content into the side-body div in the LimeSurvey 2.5 admin interface by calling the <code>PluginHelper</code> controller. As in the section above, you will need to add a new menu with an acnhor to the controller, which will in turn call your plugin action. The return value of the plugin action will be rendered in the side-body. Below is an example of a plugin that will add a menu item into the tools menu: | ||
<syntaxhighlight lang="php"> | |||
public function beforeToolsMenuRender() | |||
{ | |||
$event = $this->getEvent(); | |||
$surveyId = $event->get('surveyId'); | |||
$href = Yii::app()->createUrl( | |||
'admin/pluginhelper', // Call the plugin helper controller | |||
array( | |||
'sa' => 'sidebody', // subaction is "sidebody" | |||
'plugin' => 'MyPlugin', // Name of this plugin | |||
'method' => 'actionIndex', // Plugin action that PluginHelper will call | |||
'surveyId' => $surveyId | |||
) | |||
); | |||
$menuItem = new ExtraMenuItem(array( | |||
'label' => 'Label of the menu', | |||
'iconClass' => 'fa fa-table', | |||
'href' => $href | |||
)); | |||
$event->set('menuItems', array($menuItem)); | |||
} | |||
public function actionIndex() | |||
{ | |||
// TODO: Add view and layout | |||
return "This is the content of the side-body"; | |||
} | |||
</syntaxhighlight> | |||
[[User:Olle|Olle]] ([[User talk:Olle|talk]]) 17:17, 30 April 2016 (CEST) | [[User:Olle|Olle]] ([[User talk:Olle|talk]]) 17:17, 30 April 2016 (CEST) |
Revision as of 17:25, 30 April 2016
Why isn't newDirectRequest implemented in the base class? Seems like a generic class that mostly is not needed to override.
Olle (talk) 23:59, 29 April 2016 (CEST)
Draft:
Add new content in side-body in LimeSurvey 2.5
A plugin can add content into the side-body div in the LimeSurvey 2.5 admin interface by calling the PluginHelper
controller. As in the section above, you will need to add a new menu with an acnhor to the controller, which will in turn call your plugin action. The return value of the plugin action will be rendered in the side-body. Below is an example of a plugin that will add a menu item into the tools menu:
public function beforeToolsMenuRender()
{
$event = $this->getEvent();
$surveyId = $event->get('surveyId');
$href = Yii::app()->createUrl(
'admin/pluginhelper', // Call the plugin helper controller
array(
'sa' => 'sidebody', // subaction is "sidebody"
'plugin' => 'MyPlugin', // Name of this plugin
'method' => 'actionIndex', // Plugin action that PluginHelper will call
'surveyId' => $surveyId
)
);
$menuItem = new ExtraMenuItem(array(
'label' => 'Label of the menu',
'iconClass' => 'fa fa-table',
'href' => $href
));
$event->set('menuItems', array($menuItem));
}
public function actionIndex()
{
// TODO: Add view and layout
return "This is the content of the side-body";
}