Building a new menu like owner_block

Hello,
I am just starting to develop a theme for elgg. I want to add a menu with the links provided like by the "owner_block" to give the user a "shortcut" to his pages,files, and wire entries. Just the same one gets from owner_block on the right side....
But the function "elgg_view_menu('owner_block',..." works contextual to opened functions and changes its links.
For example:
Default
- Pages
- Files
- Wire entries

If the user changes to a group the menu changes to
- Pages of the group
- Files of the group
- Latest entries

But I want to it to stay in the default way...
Ok.. I could try to make it some kind of "hard coded" way... But I want the menu to dynamicly add new features like "Blog" if an extension is installed and the extension provides the possibilty for the user to add new entries.
LIke:
- Pages
- Files
- Wire entries
- Blog


Does anyone have some kind of "Code snippet" that could help?
Kind regards
Markus

  • If understand you correctly then you need to register page handler for it:

    elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'theme_owner_block_menu_handler');

    Read this topic also (very similar situation)

  • Hi @RvR
    first thank you for your fast response.
    But. errm.... I think I don't get it. As far as I see in the example of topic you send here it is a solution how to add a "blog" or something else to the menu if a plugin like "blog" is installed. But it's not about the blog...

    I would like to have the menu
    - Pages
    - Files
    - Wire entries


    stay all the time on my menu... even if the user is in groups or somewhere else.
    I thought maybe there is some kind of function or hook that always renders this menu.

    Of course it would be nice if the admin adds a plugin which adds a new menuentry to the "owner_block" that this menuentry will show automaticly up in my menu. But this is the the second step and could be managed by the soltion you provided.
    Kind regards
    Markus

     

  • An example for you.

    1) Make your own page handler:

    elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'theme_owner_block_menu_handler');

    2) Add items:

    function theme_owner_block_menu_handler($hook, $type, $items, $params) {
        $owner = elgg_get_page_owner_entity();


            $items['profile'] = ElggMenuItem::factory(array(
                'name' => 'profile',
                'text' => elgg_echo('profile'),
                'href' => "/profile/$owner->username/",
                'priority' => 1,
            ));


         if (elgg_is_active_plugin('thewire')) {
                $items['thewire'] = ElggMenuItem::factory(array(
                'name' => 'thewire',
                'text' => elgg_echo('thewire'),
                'href' => "/thewire/owner/$owner->username",
                'priority' => 2,
            ));
        }

        if (elgg_is_active_plugin('pages')) {
        $items['pages'] = ElggMenuItem::factory(array(
                'name' => 'pages',
                'text' => elgg_echo('pages'),
                'href' => "/pages/owner/$owner->username",
                'priority' => 3,
            ));
         }

       if (elgg_is_active_plugin('file')) {

        $items['file'] = ElggMenuItem::factory(array(
                'name' => 'file',
                'text' => elgg_echo('file'),
                'title' => elgg_echo('crewz:owner'),
                'href' => "/file/owner/$owner->username",
                'priority' => 4,
            ));
          }


        return $items;
    }

    etc

     

  • Hi @RvR

    Thank you very very much for your help!
    Ok it seems like there is only the "hard-coded" way and no hook from the elgg system.
    Thanks it works!
    Kind regards
    Markus

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