Browse code

Inject Init Code

Benjamin Roth authored on11/12/2019 14:16:27
Showing2 changed files
... ...
@@ -16,7 +16,7 @@ class TemplateListener
16 16
   {
17 17
     $Template = new \FrontendTemplate('cookieconsent');
18 18
 
19
-    $Template->parse();
20
-    return $strBuffer;
19
+    $strInject = $Template->parse();
20
+    return str_replace('</body>',$strInject . '</body>',$strBuffer);
21 21
   }
22 22
 }
23 23
\ No newline at end of file
... ...
@@ -1,2 +1,89 @@
1 1
 <?php
2
-$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/eSM_cookieconsent/assets/js/lib/cookieconsent.min.js|static';
3 2
\ No newline at end of file
3
+$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/eSM_cookieconsent/assets/js/lib/cookieconsent.min.js|static';
4
+
5
+?>
6
+
7
+<script>
8
+  window.CookieConsent.init({
9
+    // More link URL on bar
10
+    modalMainTextMoreLink: null,
11
+    // How lond to wait until bar comes up
12
+    barTimeout: 1000,
13
+    // Look and feel
14
+    theme: {
15
+      barColor: '#2C7CBF',
16
+      barTextColor: '#FFF',
17
+      barMainButtonColor: '#FFF',
18
+      barMainButtonTextColor: '#2C7CBF',
19
+      modalMainButtonColor: '#4285F4',
20
+      modalMainButtonTextColor: '#FFF',
21
+    },
22
+    language: {
23
+      // Current language
24
+      current: 'en',
25
+      locale: {
26
+        en: {
27
+          barMainText: 'This website uses cookies to ensure you get the best experience on our website.',
28
+          barLinkSetting: 'Cookie Settings',
29
+          barBtnAcceptAll: 'Accept all cookies',
30
+          modalMainTitle: 'Cookie settings',
31
+          modalMainText: 'Cookies are small piece of data sent from a website and stored on the user\'s computer by the user\'s web browser while the user is browsing. Your browser stores each message in a small file, called cookie. When you request another page from the server, your browser sends the cookie back to the server. Cookies were designed to be a reliable mechanism for websites to remember information or to record the user\'s browsing activity.',
32
+          modalBtnSave: 'Save current settings',
33
+          modalBtnAcceptAll: 'Accept all cookies and close',
34
+          modalAffectedSolutions: 'Affected solutions:',
35
+          learnMore: 'Learn More',
36
+          on: 'On',
37
+          off: 'Off',
38
+        }
39
+      }
40
+    }
41
+    // List all the categories you want to display
42
+    categories: {
43
+      // Unique name
44
+      // This probably will be the default category
45
+      necessary: {
46
+        // The cookies here are necessary and category cant be turned off.
47
+        // Wanted config value  will be ignored.
48
+        needed: true,
49
+        // The cookies in this category will be let trough.
50
+        // This probably should be false if not necessary category
51
+        wanted: true,
52
+        // If the checkbox is on or off at first run.
53
+        checked: true,
54
+        // Language settings for categories
55
+        language: {
56
+          locale: {
57
+            en: {
58
+              name: 'Strictly Necessary Cookies',
59
+              description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu commodo est, nec gravida odio. Suspendisse scelerisque a ex nec semper.',
60
+            }
61
+          }
62
+        }
63
+      }
64
+    },
65
+    // List actual services here
66
+    services: {
67
+      // Unique name
68
+      analytics: {
69
+        // Existing category Unique name
70
+        // This example shows how to block Google Analytics
71
+        category: 'necessary',
72
+        // Type of blocking to apply here.
73
+        // This depends on the type of script we are trying to block
74
+        // Can be: dynamic-script, script-tag, wrapped, localcookie
75
+        type: 'dynamic-script',
76
+        // Only needed if "type: dynamic-script"
77
+        // The filter will look for this keyword in inserted scipt tags
78
+        // and block if match found
79
+        search: 'analytics',
80
+        language: {
81
+          locale: {
82
+            en: {
83
+              name: 'Google Analytics'
84
+            }
85
+          }
86
+        }
87
+      }
88
+    }
89
+  });
90
+</script>
4 91
\ No newline at end of file