Click here if you want to read this article for the latest Piwik version

Piwik\Menu\

MenuAdmin

Contains menu entries for the Admin menu.

Plugins can implement the configureAdminMenu() method of the Menu plugin class to add, rename of remove items. If your plugin does not have a Menu class yet you can create one using ./console generate:menu.

Example

public function configureAdminMenu(MenuAdmin $menu)
{
    $menu->add(
        'MyPlugin_MyTranslatedAdminMenuCategory',
        'MyPlugin_MyTranslatedAdminPageName',
        array('module' => 'MyPlugin', 'action' => 'index'),
        Piwik::isUserHasSomeAdminAccess(),
        $order = 2
    );
}

Methods

The class defines the following methods:

addItem()

Since Piwik 2.7.0

Adds a new entry to the menu.

Signature

  • It accepts the following parameter(s):
    • $menuName (string) — The menu's category name. Can be a translation token.
    • $subMenuName (string) — The menu item's name. Can be a translation token.
    • $url (string|array) — The URL the admin menu entry should link to, or an array of query parameters that can be used to build the URL.
    • $order (int) — The order hint.
    • $tooltip (bool|string) — An optional tooltip to display or false to display the tooltip.
  • It does not return anything.

remove()

Removes an existing entry from the menu.

Signature

  • It accepts the following parameter(s):
    • $menuName (string) — The menu's category name. Can be a translation token.
    • $subMenuName (bool|string) — The menu item's name. Can be a translation token.
  • It does not return anything.

rename()

Renames a single menu entry.

Signature

  • It accepts the following parameter(s):

    • $mainMenuOriginal (Piwik\Menu\$mainMenuOriginal) —

    • $subMenuOriginal (Piwik\Menu\$subMenuOriginal) —

    • $mainMenuRenamed (Piwik\Menu\$mainMenuRenamed) —

    • $subMenuRenamed (Piwik\Menu\$subMenuRenamed) —

  • It does not return anything.

editUrl()

Edits a URL of an existing menu entry.

Signature

  • It accepts the following parameter(s):

    • $mainMenuToEdit (Piwik\Menu\$mainMenuToEdit) —

    • $subMenuToEdit (Piwik\Menu\$subMenuToEdit) —

    • $newUrl (Piwik\Menu\$newUrl) —

  • It does not return anything.

addDevelopmentItem()

Since Piwik 2.5.0

See add().

Adds a new menu item to the development section of the admin menu.

Signature

  • It accepts the following parameter(s):

    • $menuName (string) —

    • $url (array) —

    • $order (int) —

    • $tooltip (bool|string) —

  • It does not return anything.

addDiagnosticItem()

Since Piwik 2.5.0

See add().

Adds a new menu item to the diagnostic section of the admin menu.

Signature

  • It accepts the following parameter(s):

    • $menuName (string) —

    • $url (array) —

    • $order (int) —

    • $tooltip (bool|string) —

  • It does not return anything.

addPlatformItem()

Since Piwik 2.5.0

See add().

Adds a new menu item to the platform section of the admin menu.

Signature

  • It accepts the following parameter(s):

    • $menuName (string) —

    • $url (array) —

    • $order (int) —

    • $tooltip (bool|string) —

  • It does not return anything.

addSettingsItem()

Since Piwik 2.5.0

See add().

Adds a new menu item to the settings section of the admin menu.

Signature

  • It accepts the following parameter(s):

    • $menuName (string) —

    • $url (array) —

    • $order (int) —

    • $tooltip (bool|string) —

  • It does not return anything.

addManageItem()

Since Piwik 2.5.0

See add().

Adds a new menu item to the manage section of the admin menu.

Signature

  • It accepts the following parameter(s):

    • $menuName (string) —

    • $url (array) —

    • $order (int) —

    • $tooltip (bool|string) —

  • It does not return anything.