Tutorials/Indexpage

Updated for 1.8

If you are looking to overwrite the default index page on your Elgg install, then it is best to do this as a plugin in order to keep the upgrading of your Elgg install as pain free as possible.

The main Elgg index runs a plugin hook called 'index,system'. If this returns true, it assumes that another front page has been drawn and doesn't display the default page.

Therefore, you can override it by registering a function to the 'index,system' plugin hook and then returning true from that function. This means you can write exactly the front page you want without having to edit core Elgg. The Elgg community site runs on an untouched Elgg core altered through plugins, for example.)

Here's a quick overview:

  • Create your new plugin
  • In the start.php you will need something like the following:
<?php
 
function pluginname_init() {
    // Replace the default index page
    elgg_register_plugin_hook_handler('index', 'system', 'new_index');
}
 
function new_index() {
    if (!include_once(dirname(dirname(__FILE__)) . "/pluginname/pages/index.php"))
        return false;
 
    return true;
}
 
// register for the init, system event when our plugin start.php is loaded
elgg_register_event_handler('init', 'system', 'pluginname_init');
?>
  • Then, create an index page (/pluginname/pages/index.php) and use that to put the content you would like on the front page of your Elgg site.

Pre-1.8 Notes

In 1.8, the following functions were added which deprecated old and inconsistently named functions from previous Elgg versions:

elgg_register_plugin_hook_handler()
This used to be named register_plugin_hook(), and had the same argument list.
elgg_register_event_handler()
This used to be named `register_elgg_event_handler()`, and had the same argument list.

See http://docs.elgg.org/w/index.php?title=Tutorials/Indexpage&oldid=3672 for the original 1.7 version of this tutorial.

Search docs