You are here

cookie-content-blocker-wrapper.tpl.php in Cookie Content Blocker 7

Default theme implementation for the Cookie content blocker wrapper.

The original content is wrapped in a <script> tag with type "text/plain" to prevent browsers from loading content like image pixels.

Available variables:

  • $classes: The classes for the wrapper.
  • $attributes: All non-classes attributes for the wrapper.
  • $show_placeholder: Wheter or not a placeholder is visible to the end user.
  • $button_classes: The classes for the button.
  • $button_text: The cookie consent change button text.
  • $blocked_message: The message to show when content is blocked.
  • $original_content: The original content which is not rendered until consent has been given. Note that <script> tags are replaced by a place- holder tag in order to not break the 'text/plain' outer <script> tag.

File

theme/cookie-content-blocker-wrapper.tpl.php
View source
<?php

/**
 * @file
 * Default theme implementation for the Cookie content blocker wrapper.
 *
 * The original content is wrapped in a <script> tag with type "text/plain" to
 * prevent browsers from loading content like image pixels.
 *
 * Available variables:
 * - $classes: The classes for the wrapper.
 * - $attributes: All non-classes attributes for the wrapper.
 * - $show_placeholder: Wheter or not a placeholder is visible to the end user.
 * - $button_classes: The classes for the button.
 * - $button_text: The cookie consent change button text.
 * - $blocked_message: The message to show when content is blocked.
 * - $original_content: The original content which is not rendered until
 *   consent has been given. Note that <script> tags are replaced by a place-
 *   holder tag in order to not break the 'text/plain' outer <script> tag.
 *
 * @see template_preprocess()
 * @see template_process()
 */
if ($show_placeholder) {
  ?>
  <div class="<?php

  print $classes;
  ?>" <?php

  print $attributes;
  ?>>
    <div class="cookie-content-blocker__message-wrapper">
      <?php

  if ($preview) {
    ?>
        <div class="cookie-content-blocker__preview">
          <?php

    print $preview;
    ?>
        </div>
      <?php

  }
  ?>
      <div class="cookie-content-blocker__message">
        <?php

  print $blocked_message;
  ?>
      </div>
      <?php

  if ($show_button) {
    ?>
        <button class="<?php

    print $button_classes;
    ?>"><?php

    print $button_text;
    ?></button>
      <?php

  }
  ?>
    </div>
<?php

}
?>

  <!-- Begin blocked content -->
  <?php


// Always keep this 'text/plain' <script> wrapper around your original
// content. When you are manually wrapping this logic around some content
// make sure that your original content does not contain <script> tags,
// but <scriptfake> tags instead. They will be swapped automatically when
// the necessary cookies are accepted.
?>
  <script class="js-cookie-content-blocker-content" type="text/plain">
    <?php

print $original_content;
?>
  </script>
  <!-- End blocked content -->

<?php

if ($show_placeholder) {
  ?>
  </div>
<?php

}