Setting plugin / widget menu order

Hello!

I’m trying to add my plugin/widget to the left menu at a specific position under ‘Actions’ that is already occupied by a default plugin. I cannot make my plugin appear “higher up”, interspersed with the default activated plugins (only afterward, or in a separate category).

In the documentation for plugin/widget development, I see the following code sets the initial menu order:
$this->order = X;

For instance, the plugin ‘Pages’ has $this->order = 2; (from Plugins\Actions\Reports\GetPageUrls.php) and ‘Entry Pages’ has an order = 3 (from GetEntryPageUrls.php). This corresponds nicely to the order I see, so it makes sense.

A couple questions:

  1. If I put a “conflicting” order for my plugin (i.e. I also set $order=2), what happens? Should it insert where I want it to and push down the following plugins? Because it does not.

  2. If I change the order manually for the default plugins (e.g. setting $this->order = 99 in GetEntryPageUrls.php), why does the default plugin not change order (moving away from the third position in this specific example)?

  3. What is the difference in setting these initial orders in the definition of the Report (along with a $categoryId and $subcategoryId) versus managing the menu order via WidgetConfigs e.g.

public static function configure(WidgetConfig $config)
    {
        $config->setCategoryId('About Piwik');
        $config->setName('My Example Widget');
        $config->setOrder(5);
    }

Thanks in advance for the pointers!


Piwik version: 3.2.1
MySQL version: 5.7.20
PHP version: 7.2.0RC2

Go to plugins/Actions/Categories/*.php and change the order of the subcategories by setting protected $order = XX. XX should increase from 5 to 5 starting at 5.

Do the same in plugins/Events/Categories/EventsSubcategory.php and plugins/Contents/Categories/ContentsSubcategory.php.

If you have dimensions, it gets a little bit more complicated.

At the end you should have an order like this:

PagesSubcategory = 5
EntryPagesSubcategory = 10
ExitPagesSubcategory = 15
PageTitlesSubcategory = 20
Contents order = 25
OutlinksSubcategory = 30
Events = 35
DownloadsSubcategory = 40
SiteSearchSubcategory = 45

For Visitors category, search for the following string inside of the plugins folder:

$categoryId = ‘General_Visitors’

You’ll see one file per each subcategory. Open each one of them and modify the “order” property of the class to specify the order you want each subcategory to have.