Navigation does not work

I am writing a new Plugin for me. I want to create a navigation on the right side. I have a 3-column-layout with css made myself. I have registered the navigation points in my start.php with elgg_register_menu_item. In this array I gave the 'href' attribute the link to my site. I tried everything with the href attribute, every possible link I gave it.

I also tried to implement an page handler, but this also did not work. 

But this does not work. Can anybody help me? Now I have spent a lot of hours to this problem, and there is no idea what I do wrong.

  • Do you get any menu item displayed at all? Question is at where exactly the error is. Are you trying to add a new menu entry to the "page" menu that is displayed on the right side. The page menu isn't necessarily displayed on all pages though.

    A lot of the "how to do it" depends on what you are trying to achieve and what you already have done. The pagehandler wouldn't be necessary at all, if you are trying to add a menu item pointing to an already existing page.

  • I have my own navigation on the left side. I see the navigation entry, can click on them and then i get an empty side with an error "side not found". But it exists. Perhaps I have given it a false href-attribute? From where should I navigate in the href-attribute? My structure is .../myPlugin/views/default/page/menu/site1.php

    So my href-attribute looks so: href='/page/menu/'

    Is this right?

  • <?php
    elgg_register_event_handler('init', 'system', 'myPlugin_init');
    function myPlugin_init_init() {
        elgg_register_menu_item('page', array(
            'name' => 'my_pagemenu_item',
            'text' => elgg_echo('myPlugin:my_pagemenu_item_title'),
            'href' => "myPluginPage/site1",
        // routing of urls
        elgg_register_page_handler('myPluginPage', 'myPlugin_page_handler');
    function myPlugin_page_handler($page) {
        if (!isset($page[0])) {
            $page[0] = 'site1';
        $page_type = $page[0];
        switch ($page_type) {
            case 'site1':
                echo elgg_view_resource('myPlugin/site1');
                return false;
        return true;

    The elgg_register_menu_item() entry in the init function will register the menu item for the page menu and the menu entry will show up on all pages where the page menu is displayed. If you want the menu entry to show up on specific pages only, you would have to register for the 'register', 'menu:page' plugin hook instead to add the menu item dynamically (e.g. only within a specific context defined in the callback function you register for the plugin hook).

    You will need a pagehandler if you want the menu item to redirect to a page you want to provide by your plugin. In the example code the pagehandler would be "myPluginPage". When registering the menu item you can use elgg_echo() to allow for translation of the menu item text (with the language string to be shown provided by the language file(s) of your plugin). As the Pages plugin uses the "pages" pagehandler it might be better to not use "page" as pagehandler in your plugin.

    Within the pagehandler I've used the elgg_view_resource() function introduced in Elgg 2. The view to be displayed on the page your menu item directs to would have to be added then in the file mod/myPlugin/views/default/resources/myPlugin/site1.php. If you still use Elgg 1, I would suggest to look into the code of a plugin bundled with Elgg to learn how to implement the pagehandler there because it works slightly different there.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking