OFFLINE-GmbH / oc-gdpr-plugin

October CMS plugin to make websites GDPR and ePrivacy compliant
https://octobercms.com/plugin/offline-gdpr
MIT License
36 stars 20 forks source link

Allow multiple partial refresh on user decision #95

Closed damsfx closed 11 months ago

damsfx commented 1 year ago

This PR introduce the possibility to refresh multiples partials on user decision.

This may be useful if it is needed to load several parts at different position in the site content.
One use case is Google Tag Manager who needs to load snippets in the HEAD section and in the BODY section (see https://support.google.com/tagmanager/answer/6103696 2.4).

This PR does not introduce breaking changes with actual behavior, it is backward compatible.

Usage example :

[cookieBanner]
include_css = 1
update_partial = "system/gdpr.htm, system/gdpr-tagmanager.htm"
update_selector = "#gdpr-reload, #gdpr-tagmanager"
cookie_manager_page = "system/cookies"

The CookieBanner component will accept multiple update_partial and update_selector properties by separating them with a comma.

damsfx commented 1 year ago

@tobias-kuendig before considering this PR, could you tell me why you use both push and pull partial refresh in the onAccept() handler !?

https://github.com/OFFLINE-GmbH/oc-gdpr-plugin/blob/develop/components/CookieBanner.php#L95-L98

https://github.com/OFFLINE-GmbH/oc-gdpr-plugin/blob/develop/components/cookiebanner/optin.htm#L8

tobias-kuendig commented 1 year ago

IIRC, the content key was added to provide the rendered content on a constant key to any JS client that wants to do something with the response.

In theory, this is not needed as the user can override the optin partial and add their own partial updates.

damsfx commented 1 year ago

IIRC, the content key was added to provide the rendered content on a constant key to any JS client that wants to do something with the response.

In theory, this is not needed as the user can override the optin partial and add their own partial updates.

So if you want to keep the backward compatibility, you should not accept this PR.
It is not possible to push the content variable for two different partial refreshes??

The best in this case is to update the optin partial to refresh different sections of the site.