Opened 5 years ago

Closed 4 years ago

#973 closed New feature (fixed)

Plugins hook to control the order of entries in the menu

Reported by: cn_Dark Owned by:
Priority: major Milestone: Piwik 0.8 - A Web Analytics platform
Component: UI - UX (AngularJS, twig, less) Keywords:
Cc: Sensitive: no

Description

Hello,

Is it possible to hide or change the position for the main menu.
I write a plugin, and I want it to show in the first menu. And the default menu is my plugin, not dashboard.

In plugin manger, I can only desactive the plugin, and there is no way to hide the menu.

Some ideas for this feature:

  1. add hooks like this
  • "Piwik_Menu.remove" : hide the menu

-"Piwik_Menu.move" : change the position of menu
-"Piwik_Menu.default":set the default menu to show when we visit piwik/index.php
With these hooks, we can write a plugin to achieve this feature.

  1. In "Settings"->"plugins",add some options for this feature.

Advanced feature:

  1. Administrators can show different menu for different user.
    • With hooks, developers can write a plugin to achieve this feature. But I think it will be better to add it in 'settings'.
  1. Visitors can directly move or remove the menu in UI.


Change History (6)

comment:1 Changed 5 years ago by vipsoft (robocoder)

  • Milestone set to 2- DigitalVibes

I don't think hooks should be used to change the behaviour of other plugins. Once #24 is done, it should be possible for plugins to provide this level of configurability.

In the meantime, please look at core/PluginsFunctions/Menu.php. You might be able to use Piwik_RenameMenuEntry() and Piwik_EditMenuUrl(). If you need more functionality here, submit a patch for your use case.

comment:2 Changed 5 years ago by matt (mattab)

  • Summary changed from hide or change the position of menu to Plugins hook to control the order of entries in the menu

One change might be to have the menu based on priorities to decide the order.

For example, dashboard would be priority 10, Actions = 20, Referers = 30, etc.
Then a method would allow to change priority of a given menu entry.

Any new menu added could put itself first (by setting any priority < 10), or in the middle of any other menu entry (for example, priority = 15 would put it after dashboard before Actions)

comment:3 Changed 5 years ago by matt (mattab)

  • Milestone changed from 2- DigitalVibes to 2 - Piwik 0.8 - A Web Analytics platform

comment:4 Changed 5 years ago by cn_Dark

I think hide some menus is also necessary. Sometimes we don't want to show some menu but we want it be actived.

comment:5 Changed 4 years ago by matt (mattab)

This was implemented in Admin menus recently, see the function and code in: http://dev.piwik.org/trac/browser/trunk/core/PluginsFunctions/AdminMenu.php#L105

function Piwik_AddAdminMenu( $adminMenuName, $url, $displayedForCurrentUser = true, $order = 10 )

This could be done for the normal menu, and top bar menu too.

comment:6 Changed 4 years ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from new to closed

This was fixed in #1403

Note: See TracTickets for help on using tickets.