Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Plugins to override .directive.html similar to twig templates #15843

Closed
Findus23 opened this issue Apr 22, 2020 · 9 comments
Closed

Allow Plugins to override .directive.html similar to twig templates #15843

Findus23 opened this issue Apr 22, 2020 · 9 comments
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.

Comments

@Findus23
Copy link
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.

@Findus23 Findus23 added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label Apr 22, 2020
@tsteur tsteur added the c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. label Apr 22, 2020
@tsteur tsteur added this to the Backlog (Help wanted) milestone Apr 22, 2020
@tsteur
Copy link
Member

tsteur commented Apr 22, 2020

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
Copy link
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
Copy link
Contributor

tassoman commented Jun 8, 2020

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
Copy link
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
Copy link
Member Author

@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
Copy link
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
Copy link
Member

tsteur commented Oct 26, 2020

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

@tsteur
Copy link
Member

tsteur commented Sep 22, 2022

fyi @Findus23 with Angular being removed in 5.x-dev we can maybe close this one?

@sgiehl
Copy link
Member

sgiehl commented Oct 6, 2022

With vue it won't be easily possible to overwrite the templates for certain components as they are included in the vue files.
Will close this as won't fix.

@sgiehl sgiehl closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2022
@sgiehl sgiehl added the wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it. label Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

4 participants