Actions

Talk

Talk:Add new menu and view by a plugin

From LimeSurvey Manual

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
            )
        );
        // TODO: Class ExtraMenuItem is not part of core yet
        $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";
    }

Olle (talk) 17:17, 30 April 2016 (CEST)