Tutorials/Indexpage

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. (We recommend you develop this way. 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() {
    // Extend system CSS with our own styles
    extend_view('css','pluginname/css');
    // Replace the default index page
    register_plugin_hook('index','system','new_index');
}
 
function new_index() {
    if (!include_once(dirname(dirname(__FILE__))) . "/pluginname/index.php")
        return false;
 
    return true;
}
 
// register for the init, system event when our plugin start.php is loaded
register_elgg_event_handler('init','system','pluginname_init');
?>
  • Then, create an index page (/pluginname/index.php) and use that to put the content you would like on the front page of your Elgg site.

For an example of what can be done with your custom index page, take a look at this plugin.

Search docs