Hallo Welt

This tutorial shows you how to create a new plugin that consists of a new page with the text „Hello world“ on it.

Before anything else, you need to install Elgg.

In this tutorial we will pretend your site’s URL is https://elgg.example.com.

First, create a directory that will contain the plugin’s files. It should be located under the mod/ directory which is located in your Elgg installation directory. So in this case, create mod/hello/.

Manifest file

Elgg requires that your plugin has a manifest file that contains information about the plugin. Therefore, in the directory you just created, create a file called manifest.xml and copy this code into it:

<?xml version="1.0" encoding="UTF-8"?>
<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
    <name>Hello world</name>
    <author>Your Name Here</author>
    <description>Hello world, testing.</description>

This is the minimum amount of information in a manifest file:

  • <name> is the display name of the plugin
  • <id> must be the same as the directory you just created
  • <requires> must include which version of Elgg your plugin requires
  • <author>, <version> and <description> should have some appropriate values but can be filled freely


Next, create start.php in the mod/hello/ directory and copy this code into it:


elgg_register_event_handler('init', 'system', 'hello_world_init');

function hello_world_init() {


The above code tells Elgg that it should call the function hello_world_init() once the Elgg core system is initiated.

Registrierung eines Pagehandlers

The next step is to register a page handler which has the purpose of handling request that users make to the URL https://elgg.example.com/hello.

Update start.php to look like this:


elgg_register_event_handler('init', 'system', 'hello_world_init');

function hello_world_init() {
    elgg_register_page_handler('hello', 'hello_world_page_handler');

function hello_world_page_handler() {
    echo elgg_view_resource('hello');

The call to elgg_register_page_handler() tells Elgg that it should call the function hello_world_page_handler() when a user navigates to https://elgg.example.com/hello/*.

The hello_world_page_handler() passes off rendering the actual page to a view file called hello.php.

View file

Create mod/hello/views/default/resources/hello.php with this content:


$params = array(
    'title' => 'Hello world!',
    'content' => 'My first page!',
    'filter' => '',

$body = elgg_view_layout('content', $params);

echo elgg_view_page('Hello', $body);

The code creates an array of parameters to be given to the elgg_view_layout() function, including:

  • Den Titel der Seite
  • Den Inhalt der Seite
  • Einen Filter, der allerdings leer ist, da momentan nichts zu filtern ist

Dadurch wird das grundlegende Layout der Seite definiert. Diese Layout-Definition wird dann von der elgg_view_page()-Funktion verarbeitet, die den Inhalt der Seite zusammenstellt und sie schließlich darstellt.

Last step

Finally, activate the plugin through your Elgg administrator page: https://elgg.example.com/admin/plugins (the new plugin appears at the bottom).

You can now go to the address https://elgg.example.com/hello/ and you should see your new page!