How to build Elgg plugin

10/05/2015


UPDATE: There is a video tutorial covering same topic.


New Elgg users assume that you have to be programmer to build plugins, and they don't even try to build plugin. They often do simple customizations by modifying core files. This is not a good idea since you will lose all your changes on next Elgg version upgrade. Also you can easily break things this way, and you can not just disable changes like with custom built plugin.


 If you get White Screen Of Death when you are making changes to your plugin and you cannot access admin panel to disable plugin, just create empty file with name "disabled" in your mod/ directory. This will disable all plugins and you will have access to administration panel to disable problematic plugin.


Building plugin


1. Create new folder in mod/ directory an call it whatever you want. For this tutorial i will call it "quick". This will be the name of plugin.


2. Create manifest.xml file in quick directory which gives basic information about plugin. The easiest way is to copy manifest.xml from any other elgg plugin and change it for your plugin.


You have to change <name> and <id> elements to quick.



    <name>quick</name>

    <id>quick</id>



Read more about manifest file and other elements in elgg documentation.


3. Create empty start.php file in quick directory. Every plugin need start.php  to work, but you don't have to put any code in it for now.


Congratulation, you just built your first elgg plugin, you can go to plugins administration and enable it. This plugin doesn't do anything yet and in next step we will add new functionality.


 You need to turn off elgg caching to see changes you make with your new plugin. Enable Elgg Developer Tools plugin and in Develop>Settings page turn off both simple and system caching.


Change wording


Create folder called "languages" inside quick plugin folder and create file called en.php. Open en.php and paste this code in it:



<?php

return array(

    'blog' => 'Notes',

    'blog:blogs' => 'Notes'

);



This will change  wording for blog plugin, and now in main manu and user menu there is "Notes" link instead of  "Blogs".