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
Add OptOut hook #7979
Add OptOut hook #7979
Conversation
Would it be possible to listen to the |
Sure but then I have to parse the rendered HTML to add some css. I think its a much better way to change the view object and extends the twig template. |
I totally understand that. Problem is that needs are so differently, we'd probably end up adding an event in each action at some point. That's why we introduced those generic ones. Also understand re the view. One problem I see here is that we don't have a "process" for keeping backwards compatibility for templates. We do not see templates as a public API so far (and I doubt it will change since we want to render everything in the browser anyway). Meaning it would be easily possible that at some point someone will remove those twig blocks and your custom opt out would no longer work. If we do here something, I'd rather post an event in the template directly similar to https://github.com/piwik/piwik/blob/2.14.0-b1/plugins/CoreHome/templates/_topBar.twig#L1 . This way at least everyone would be aware that there is something we should to keep BC. Still, we usually don't add those events directly in the template and try to avoid them. They will be also not documented and it could still happen that we remove them. Do you need all three blocks? They basically cover the whole page to be replaced? |
I need just one twig block in the head section and a event in the controller action to inject the custom css style. I can change my commit and remove the other twig blocks. |
@tsteur maybe we could add a new generic event in View->render(), that would pass the View object as parameter? |
That would be possible but maybe a bit fragile? Eg the template name might change over time when doing I'm not really sure of the benefit as one cannot change the As template names become API I would not really want to do that. |
Another way could be to create a OptOutManager which include the whole optout logic. This manager could be trigger some events to extends / replace the OptOut logic and finally return the view object. Currently the CoreAdminHome controller includes some optout logic, that may be better placed in a seperate manager / service. |
I agree the OptOut can be quite an important part for someone that uses Piwik as it is visible on the website etc. It would be nice to be able to make some more tweaks. I'd prefer not letting users change the view or templates but provide specific API's to change behaviour or look. The look could be eg changed with additional custom CSS files, we could users allow to add JS files to the header as well. We could also add some disable/enable options. This wouldn't be via Twig or View but via a method that can be called on the I presume it shouldn't be too much work to do such things. Class could be like
|
I agree that it shouldn't be much work to create this OptOutManager. If it is ok for you, i can work on it and create new pr. |
👍 that would be very much appreciated and for sure many users would benefit from it |
I close this PR in favor of PR #8229 |
In relation to issue #7962