<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.limesurvey.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jdd2405</id>
	<title>LimeSurvey Manual - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.limesurvey.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jdd2405"/>
	<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/Special:Contributions/Jdd2405"/>
	<updated>2026-08-16T21:18:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Add_new_menu_and_view_by_a_plugin&amp;diff=64355</id>
		<title>Add new menu and view by a plugin</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Add_new_menu_and_view_by_a_plugin&amp;diff=64355"/>
		<updated>2015-02-20T11:08:37Z</updated>

		<summary type="html">&lt;p&gt;Jdd2405: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to write a plugin that adds a menu to the admin menubar &amp;amp; when clicked renders some content &lt;br /&gt;
&lt;br /&gt;
1. Create a new plugin. let us call it Rewards&lt;br /&gt;
&lt;br /&gt;
2. register for events afterAdminMenuLoad and newDirectRequest in the constructor&lt;br /&gt;
&lt;br /&gt;
3. implement the above methods methods in the new plugin class&lt;br /&gt;
&lt;br /&gt;
4. In the method afterAdminMenuLoad, add a new menu item and link it to &lt;br /&gt;
    admin/plugins/direct?plugin=&amp;lt;plugin_name&amp;gt;&amp;amp;function=&amp;lt;plugin_action&amp;gt;&lt;br /&gt;
    e.g&lt;br /&gt;
    admin/plugins/direct?plugin=rewards&amp;amp;function=assignRewards&lt;br /&gt;
The best way to to this would be to make use of the createURL method:&lt;br /&gt;
    &#039;href&#039; =&amp;gt; $this-&amp;gt;api-&amp;gt;createUrl(&#039;plugins/direct&#039;, array(&#039;plugin&#039; =&amp;gt; &#039;Rewards&#039;, &#039;function&#039; =&amp;gt; &#039;assignRewards&#039;)),&lt;br /&gt;
&lt;br /&gt;
5. implement the method newDirectRequest &lt;br /&gt;
&lt;br /&gt;
    public function newDirectRequest(){&lt;br /&gt;
        $event = $this-&amp;gt;event;&lt;br /&gt;
        &lt;br /&gt;
        // you can get other params from the request object&lt;br /&gt;
        $request = $event-&amp;gt;get(&#039;request&#039;);&lt;br /&gt;
        &lt;br /&gt;
        //get the function name to call and use the method call_user_func&lt;br /&gt;
        $functionToCall = $event-&amp;gt;get(&#039;function&#039;);        &lt;br /&gt;
        $content = call_user_func(array($this,$functionToCall)); &lt;br /&gt;
        //set the content on the event      &lt;br /&gt;
        $event-&amp;gt;setContent($this, $content);        &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. implement the method plugin_action, in our case it is assignRewards(). &lt;br /&gt;
In this method currently i am just trying to return some dummy content, you can have sophisticated page rendered. &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;public function assignRewards() {&lt;br /&gt;
        $content = &amp;quot;&amp;lt;h1&amp;gt; plugin content set succesfully &amp;lt;/h1&amp;gt;&amp;quot;;&lt;br /&gt;
        return $content;        &lt;br /&gt;
    }&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
7. The full Rewards.php &lt;br /&gt;
[[File:Rewards1.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. This is how the UI looks now.&lt;br /&gt;
[[File:Screenshot_2014-08-21_01.34.05.png]]&lt;/div&gt;</summary>
		<author><name>Jdd2405</name></author>
	</entry>
	<entry>
		<id>https://www.limesurvey.org/manual/index.php?title=Add_new_menu_and_view_by_a_plugin&amp;diff=64354</id>
		<title>Add new menu and view by a plugin</title>
		<link rel="alternate" type="text/html" href="https://www.limesurvey.org/manual/index.php?title=Add_new_menu_and_view_by_a_plugin&amp;diff=64354"/>
		<updated>2015-02-20T11:07:16Z</updated>

		<summary type="html">&lt;p&gt;Jdd2405: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to write a plugin that adds a menu to the admin menubar &amp;amp; when clicked renders some content &lt;br /&gt;
&lt;br /&gt;
1. Create a new plugin. let us call it Rewards&lt;br /&gt;
&lt;br /&gt;
2. register for events afterAdminMenuLoad and newDirectRequest in the constructor&lt;br /&gt;
&lt;br /&gt;
3. implement the above methods methods in the new plugin class&lt;br /&gt;
&lt;br /&gt;
4. In the method afterAdminMenuLoad, add a new menu item and link it to &lt;br /&gt;
    admin/plugins/direct?plugin=&amp;lt;plugin_name&amp;gt;&amp;amp;function=&amp;lt;plugin_action&amp;gt;&lt;br /&gt;
    e.g&lt;br /&gt;
    admin/plugins/direct?plugin=rewards&amp;amp;function=assignRewards&lt;br /&gt;
The best way to to this would be to make use of the createURL method:&lt;br /&gt;
&#039;href&#039; =&amp;gt; $this-&amp;gt;api-&amp;gt;createUrl(&#039;plugins/direct&#039;, array(&#039;plugin&#039; =&amp;gt; &#039;Rewards&#039;, &#039;function&#039; =&amp;gt; &#039;assignRewards&#039;)),&lt;br /&gt;
&lt;br /&gt;
5. implement the method newDirectRequest &lt;br /&gt;
&lt;br /&gt;
    public function newDirectRequest(){&lt;br /&gt;
        $event = $this-&amp;gt;event;&lt;br /&gt;
        &lt;br /&gt;
        // you can get other params from the request object&lt;br /&gt;
        $request = $event-&amp;gt;get(&#039;request&#039;);&lt;br /&gt;
        &lt;br /&gt;
        //get the function name to call and use the method call_user_func&lt;br /&gt;
        $functionToCall = $event-&amp;gt;get(&#039;function&#039;);        &lt;br /&gt;
        $content = call_user_func(array($this,$functionToCall)); &lt;br /&gt;
        //set the content on the event      &lt;br /&gt;
        $event-&amp;gt;setContent($this, $content);        &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. implement the method plugin_action, in our case it is assignRewards(). &lt;br /&gt;
In this method currently i am just trying to return some dummy content, you can have sophisticated page rendered. &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;public function assignRewards() {&lt;br /&gt;
        $content = &amp;quot;&amp;lt;h1&amp;gt; plugin content set succesfully &amp;lt;/h1&amp;gt;&amp;quot;;&lt;br /&gt;
        return $content;        &lt;br /&gt;
    }&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
7. The full Rewards.php &lt;br /&gt;
[[File:Rewards1.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. This is how the UI looks now.&lt;br /&gt;
[[File:Screenshot_2014-08-21_01.34.05.png]]&lt;/div&gt;</summary>
		<author><name>Jdd2405</name></author>
	</entry>
</feed>