Matomo contains 3 menus:
the top menu (top-right of the page)
the reporting menu (which includes all the reports like "Actions" and "Visitors")
the admin menu (shown in the admin panel)
Plugins can add items to these menus by implementing a Menu
class. To add new items to the reporting menu you need
to create a new Widget.
To add a menu class to your plugin, use the console:
$ ./console generate:menu
It will create a plugins/MyPlugin/Menu.php
file:
class Menu extends \Piwik\Plugin\Menu
{
public function configureTopMenu(MenuTop $menu)
{
// ...
}
public function configureAdminMenu(MenuAdmin $menu)
{
// ...
}
}
Note: URLs can be built using the controller methods:
$this->urlForDefaultAction()
returns the default action (index) for the controller of this plugin$this->urlForAction('foo')
returns the URL for the action foo
for the controller of this plugin public function configureTopMenu(MenuTop $menu)
{
$menu->addItem('My top item', null, $this->urlForDefaultAction());
}
public function configureAdminMenu(MenuAdmin $menu)
{
// add items to an existing category
$menu->addSettingsItem('My admin item', $this->urlForDefaultAction());
$menu->addPlatformItem('My admin item', $this->urlForDefaultAction());
// or create a custom category
$menu->addItem('MyPlugin admin settings', 'My admin item', $this->urlForDefaultAction());
}
To add or change items in the reporting menu you need to create a new Widget.