Forums | Mahara Community

Developers /
main_nav


Osbel Rondón's profile picture
Posts: 23

11 May 2017, 2:48 PM

Hello

I have this problem. I´ve implemented the local_main_nav_update function into the lib.php file of a personal plugin, to add a menu item as follow:

function local_main_nav_update(&$menu){  
    $menu['courses'] = array(
        'path' => 'courses',
        'title' => 'Courses',
        'url' => 'auth/mymodule/courses.php',
        'weight' => 300
    );
}

However the item is printed when a user is logged in, but when other page is loaded or the dashborad page is reloaded, the menu item disappears.

Any body know why?

Regards

Robert Lyon's profile picture
Posts: 355

11 May 2017, 5:05 PM

Hi Osbel,

It sounds like you've not quite set things up right.

The local_main_nav_update() function is not meant to added to your plugin but was designed for adding some custom menu items via having a htdocs/local/lib.php file (this file if exists is included for all pages).

Putting it in your plugin means the menu only will show if your plugin is included for the page.

What you should be using within your plugin is the:

   public static function menu_items()

See the htdocs/artefact/resume/lib.php for an example

There are also options for admin_menu_items() , institution_menu_items()  and institution_staff_menu_items() in case you only want your menu items to appear for users with certain privilege levels

Note: with placing the menus in this way you'll need to use the 'clear cache' button on Admin homepage to get a fresh menu.

Cheers

Robert

Osbel Rondón's profile picture
Posts: 23

12 May 2017, 3:28 AM

thank you so much Robert,
Precisely that was the problem and it is already solved
regards
Osbel

3 results