Piwik\Menu\

MenuTop

Contains menu entries for the Top menu (the menu at the very top of the page).

Plugins can implement the configureTopMenu() 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.

Methods

The class defines the following methods:

getInstance()

Returns the singleton instance for the derived class. If the singleton instance has not been created, this method will create it.

Signature

addItem()

Since Matomo 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.
    • $icon (bool|string) — An icon classname, such as "icon-add". Only supported by admin menu
    • $onclick (bool|string) — Will execute the on click handler instead of executing the link. Only supported by admin menu.
    • $attribute (string) — Will add this string as a link attribute.
    • $help (bool|string) — Will display a help icon that will pop a notification with help information.
  • It does not return anything or a mixed result.

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 or a mixed result.

rename()

Renames a single menu entry.

Signature

  • It accepts the following parameter(s):

    • $mainMenuOriginal

    • $subMenuOriginal

    • $mainMenuRenamed

    • $subMenuRenamed

  • It does not return anything or a mixed result.

editUrl()

Edits a URL of an existing menu entry.

Signature

  • It accepts the following parameter(s):

    • $mainMenuToEdit

    • $subMenuToEdit

    • $newUrl

  • It does not return anything or a mixed result.

addHtml()

Directly adds a menu entry containing html.

Signature

  • It accepts the following parameter(s):

    • $menuName (string) —

    • $data (string) —

    • $displayedForCurrentUser (boolean) —

    • $order (int) —

    • $tooltip (string) — Tooltip to display.

  • It does not return anything or a mixed result.