Warning: This page has not been updated in over over a year and may be outdated or deprecated.
configuration:cookie_consent
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
configuration:cookie_consent [2022/09/07 08:38] – emaijala | configuration:cookie_consent [2022/09/30 09:26] (current) – [JavaScript Events] emaijala | ||
---|---|---|---|
Line 4: | Line 4: | ||
The cookie consent prompt and settings allow the user to be informed about cookies used by the service and manage consent for non-essential cookies. | The cookie consent prompt and settings allow the user to be informed about cookies used by the service and manage consent for non-essential cookies. | ||
+ | |||
+ | ===== Configuration ===== | ||
+ | |||
+ | The configuration for enabling cookie consent is in the Cookies section of config.ini. It contains the settings to turn on cookie consent and select the categories to display and allow toggling in the cookie settings dialog. | ||
+ | |||
+ | Cookie categories and further configuration is in CookieConsent.yaml. See the comments in the file and the sample configurations below for further information. | ||
+ | |||
+ | Note that if enabled categories or cookies in the categories are changed, the **consentRevision setting in config.ini must be incremented**. This makes VuFind re-request consent and ensures that invalid categories do not remain in the consent cookie. There is also '' | ||
+ | |||
+ | Default translation texts include a link to the [[configuration: | ||
+ | |||
+ | ===== Language Translations ===== | ||
+ | |||
+ | Most text strings used in the cookie consent component have translations in the CookieConsent [[development: | ||
+ | |||
+ | ===== Information for Developers ===== | ||
+ | |||
+ | ==== Checking for Consent ==== | ||
+ | |||
+ | You can check for user's consent in phtml templates: | ||
+ | <code php> | ||
+ | <?php if ($this-> | ||
+ | <?php if ($this-> | ||
+ | Essential category is accepted (as it should be)! | ||
+ | <?php endif; ?> | ||
+ | <?php if ($this-> | ||
+ | Matomo service is allowed! | ||
+ | <?php endif; ?> | ||
+ | <?php endif; ?> | ||
+ | </ | ||
+ | |||
+ | You can also check consent in JavaScript: | ||
+ | <code javascript> | ||
+ | if (VuFind.cookie.isCategoryAccepted(' | ||
+ | if (VuFind.cookie.isServiceAllowed(' | ||
+ | </ | ||
+ | |||
+ | ==== JavaScript Events ==== | ||
+ | |||
+ | The following events are emitted: | ||
+ | |||
+ | ^ Event ^ Description | ||
+ | | vf-cookie-consent-first-done | ||
+ | | vf-cookie-consent-done | ||
+ | | vf-cookie-consent-changed | ||
+ | | vf-cookie-consent-initialized | ||
===== Sample Configurations ===== | ===== Sample Configurations ===== | ||
Line 17: | Line 63: | ||
:!: At least expiration times may differ depending on region. | :!: At least expiration times may differ depending on region. | ||
- | The following configuration | + | The following |
- | + | ||
- | < | + | |
- | <div class=" | + | |
- | </ | + | |
- | + | ||
- | You can also check if iframe manager is active: | + | |
+ | Template example: | ||
<code php> | <code php> | ||
- | | + | <? |
- | <div style=" | + | <?php if (!$cookieConsent-> |
- | <?php else: ?> | + | <iframe width=" |
- | <iframe width=" | + | <?php else: ?> |
- | <?php endif; ?> | + | |
+ | <p> | ||
+ | The video cannot be displayed due to missing cookie consent. | ||
+ | Check <a href="#" | ||
+ | </ | ||
+ | <p> | ||
+ | You can also view the video on <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | <?php endif; ?> | ||
</ | </ | ||
Line 42: | Line 92: | ||
DefaultEnabled: | DefaultEnabled: | ||
Essential: false | Essential: false | ||
- | ControlIframeServices: | ||
- | - youtube | ||
Cookies: | Cookies: | ||
- Name: yt-player-bandwidth | - Name: yt-player-bandwidth | ||
Line 80: | Line 128: | ||
AutoClearCookies: | AutoClearCookies: | ||
- Name: '/ | - Name: '/ | ||
- | IframeServices: | ||
- | youtube: | ||
- | EmbedUrl: ' | ||
- | # | ||
- | IframeAllow: | ||
- | Description: | ||
- | AllowOnceText: | ||
- | AllowAlwaysText: | ||
- | </ | ||
- | |||
- | ==== Iframe Manager ==== | ||
- | |||
- | If you use iframe manager (like in the YouTube video example above), add this to the '' | ||
- | |||
- | <code yaml> | ||
- | - Name: ' | ||
- | Domain: ' | ||
- | Description: | ||
- | Expiration: ' | ||
- | ExpirationUnit: | ||
</ | </ | ||
---- struct data ---- | ---- struct data ---- | ||
- | properties.Page Owner : | + | properties.Page Owner : emaijala |
---- | ---- | ||
configuration/cookie_consent.1662539883.txt.gz · Last modified: 2022/09/07 08:38 by emaijala