@Findus23 opened this Issue on April 22nd 2020 Member

Plugins/Themes can change how content is rendered either by listening to events in the template or by completely replacing the file in the plugin:

https://developer.matomo.org/guides/theming#twig-the-template-engine

Now that more parts are written in angular, this possibility dissapears, and we should document another way plugins can easily customize pages.

@tsteur commented on April 22nd 2020 Member

Just FYI: As with the templates, the same would apply to these HTML files that the structure could change at any time and we can't consider any of the variables we assign to the template part of API and keep BC.

@tassoman commented on April 22nd 2020 Contributor

When a template gets overwritten, I think keeping BC or staying update with changes should be a duty of the plugin author, the templates overwriter.

@tassoman commented on June 8th 2020 Contributor

Let's do a practical example:

as plugin developer I would like to remove «custom» ranges from regular users selection, in order to avoid custom report calculations

Istantanea_2020-06-08_17-23-43

            <div
                    id="comparePeriodToDropdown"
                    piwik-field
                    name="comparePeriodToDropdown"
                    uicontrol="select"
                    options="[{key: 'previousPeriod', value: 'Previous period'}, {key: 'previousYear', value: 'Previous year'}]"
                    ng-model="periodSelector.comparePeriodType"
                    full-width="true"
                    disabled="!periodSelector.isComparing"
            ></div>

I need to edit the array of options, removing the first item: {key: 'custom', value: 'Custom period'} in a conditional mode (by user's privileges).

Doing this goes deeper in the Matomo's UI, but, you know, you can already go deep using jQuery inside a plugin's javascript asset. As you can see, the last «custom» choice from the range list is already gone.
I need to remove the «custom report» from comparison. Angular components aren't reachable by jQuery.

@tassoman commented on October 26th 2020 Contributor

Hello there, I want to inform you that my plugin upgrade path to 4.x-dev is blocked by this still opened issue.
In the past, we used jQuery to do the dirt stuff, but, since Angular introduction, jQuery got overridden.

@Findus23 commented on October 26th 2020 Member

@tassoman While I agree that solving this issue would be the right thing to do, I am not sure why your solution wouldn't work any more with Matomo 4. Nothing changed (Matomo used Angular and jQuery before) apart from updating the versions of a few of them. If you want to, I can take a look at how RerUserDates.js will continue to work.

@tassoman commented on October 26th 2020 Contributor

The «compare to» select field is populated on rendering, by an array of values can't be overridden anyway (I'm aware of)
ng-model="periodSelector.comparePeriodType"

@tsteur commented on October 26th 2020 Member

BTW probably it won't help but maybe it's possible to hide certain options through CSS?

Powered by GitHub Issue Mirror