Forums | Mahara Community

Developers /
hook into admin menu


anonymous profile picture
Deleted user
Posts: 2

20 June 2011, 8:53 AM

How does one inject items into the admin menu?

Iñaki Arenaza's profile picture
Posts: 253

21 June 2011, 2:02 AM

I was going to reply that the only way I know of was directly editing the admin menu in admin_nav() (lib/web.php), but then I had a look at the code to build the menus and noticed that you can define a local function in local/lib.php called local_main_nav_update(). You are passed the whole menu structure and you can modify it as much as you want: add entries, remove entries, or change them :-)

You should check if the current user is an admin before doing any edits (as the function is called both for admin menu and regular user menu). You can see how Mahara checks for that by having a look at the first few lines of main_nav() (lib/web.php)

Edit: but see https://bugs.launchpad.net/mahara/+bug/799989 for difficulties you may encounter there

Saludos.
Iñaki.

anonymous profile picture
Deleted user
Posts: 2

21 June 2011, 8:09 AM

Thanks but we are trying to do this for plugin rather than our local install

Is there a way for a plugin to do it

We're writing a plugin that has admin pages and we want those to appear in the admin menu

Iñaki Arenaza's profile picture
Posts: 253

21 June 2011, 2:52 PM

According to the bug I refereced above (https://bugs.launchpad.net/mahara/+bug/799989) there's no way to do it from plugins (and Richard Mansfield is a core developer, so he should be authoritative on the subject :-))

Saludos.
Iñaki.

François Marier's profile picture
Posts: 411

21 June 2011, 5:52 PM

Not yet, but we are working on it:

  https://reviews.mahara.org/#change,357

and so it should be possible in Mahara 1.5.

Cheers,

Francois

5 results