Plugin Tutorials 101 - Basic Menu plugin
From e107 Wiki
e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page
Tutorial 101 - a basic menu plugin
Plugins are installable features, such as a calendar, a menu or an application of any sort.
Just like with Mr. Potato Head, you can put on these ears and that nose, then change your mind and put on different ears. With e107 you don’t have to reprogram or modify the code... if someone has written a plugin, you can use it too.
How do I write one?
This hands-on tutorial will help you write the simplest plugin so that you can get the idea. It is missing many features and safety checks but it works.
The task this plugin will perform will add a promotion link on your web site. The plugin will show a pretty picture under a title. Click an the picture to link to a page you wish to promote.
This plugin will be a menu plugin. It goes in the menu pane (the side menus) and not in the content pane (the middle section).
The tutorial promo is for a tent sale. It will look like this;
Buy our tents. Picture.
Go to your website directory. Go to the e107_plugin directory. Create a new directory called promo_menu.
mkdir promo_menu chmod 777 promo_menu <-- this is only required for scripts needing to write in the folder.
Go into the directory.
Copy a small picture into this directory.
Rename it to “tents.jpg”
Create a new file called promo_menu.php Insert the following code.
Note that e_BASE will be converted into the root dir path of your e107 installation and e_PLUGIN the plugins folder path. Now, upload your files to the promo_menu folder and then go to your admin -> menus area and enable 'promo' in one of the menu areas. If you wish to add admin configuration options, database tables and preferences etc please read on - you will need to make a plugin.php file.
How to make it install (Optional for Menus)
There is only one file needed to get this plugin to install into the admin interface. plugin.php contains the instructions needed by the plugin manager. The plugin.php file looks like this;
Are you ready?
Make sure you have the following three files in the promo directory.
promo_menu.php plugin.php tents.jpg
Pull up your website. Login as an administrator. Select the plugin manager. Promo will show in the uninstalled list, but does not have an Install button as it does not need to be installed.
This makes promo available to e107. We need to activate it before it will show up.
Activating the promo
Click Content/Menus. Locate Promo in the inactive list. Activate it in area 1. Find promo in area 1 and using the dropdown box move to top.
Go to your home page and observe the fruits of your labour.
--Written by Strider22 01:03, 30 July 2006 (CDT)