Piwik\Plugin\
Since Matomo 2.4.0
Base class of all plugin menu providers.
Descendants of this class can overwrite any of these methods. Each method will be executed only once per request and cached for any further menu requests.
For an example, see the https://github.com/piwik/piwik/blob/master/plugins/ExampleUI/Menu.php plugin.
The class defines the following methods:
__construct()
urlForDefaultAction()
— Generates a URL for the default action of the plugin controller.urlForAction()
— Generates a URL for the given action.urlForDefaultUserParams()
— Returns the &idSite=X&period=Y&date=Z query string fragment, fetched from current logged-in user's preferences.configureTopMenu()
ash; Configures the top menu which is supposed to contain analytics related items such as the "All Websites Dashboard".configureAdminMenu()
ash; Configures the admin menu which is supposed to contain only administration related items such as "Websites", "Users" or "Settings".__construct()
urlForDefaultAction()
Since Matomo 2.7.0
Generates a URL for the default action of the plugin controller.
Example:
$menu->addItem('MyPlugin_MyPlugin', '', $this->urlForDefaultAction(), $orderId = 30);
// will add a menu item that leads to the default action of the plugin controller when a user clicks on it.
// The default action is usually the `index` action - meaning the `index()` method the controller -
// but the default action can be customized within a controller
$additionalParams
(array
) —
Optional URL parameters that will be appended to the URLarray
value.urlForAction()
Since Matomo 2.7.0
Generates a URL for the given action. In your plugin controller you have to create a method with the same name as this method will be executed when a user clicks on the menu item. If you want to generate a URL for the action of another module, meaning not your plugin, you should use the method urlForModuleAction().
$controllerAction
(string
) —
The name of the action that should be executed within your controller$additionalParams
(array
) —
Optional URL parameters that will be appended to the URLarray
value.urlForDefaultUserParams()
Returns the &idSite=X&period=Y&date=Z query string fragment, fetched from current logged-in user's preferences.
It accepts the following parameter(s):
$websiteId
(bool
) —
$defaultPeriod
(bool
) —
$defaultDate
(bool
) —
Returns: array
—
eg ['idSite' => 1, 'period' => 'day', 'date' => '2012-02-03']
Exception
— in case a website was not specified and a default website id could not be foundconfigureTopMenu()
Configures the top menu which is supposed to contain analytics related items such as the "All Websites Dashboard".
It accepts the following parameter(s):
$menu
(MenuTop
) —It does not return anything or a mixed result.
configureAdminMenu()
Configures the admin menu which is supposed to contain only administration related items such as "Websites", "Users" or "Settings".
It accepts the following parameter(s):
$menu
(MenuAdmin
) —It does not return anything or a mixed result.