Ledger Nano X - The secure hardware wallet
SHARE
TWEET

D8 comments

Juc1 Jun 26th, 2018 (edited) 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $:/data/disk/o1/static/z-d8-themes/orange# ls
  2. css/  js/  orange.info.yml  orange.libraries.yml  orange.theme  templates/
  3. $:/data/disk/o1/static/z-d8-themes/orange# cat orange.info.yml
  4. name: orange
  5. type: theme
  6. description: This is a sub theme of Bartik
  7. core: 8.x
  8. # Defines the base theme
  9. base theme: bartik
  10. # Defines libraries group in which we can add css/js.
  11. libraries:
  12.   - orange/global-styling
  13.  
  14. $:/data/disk/o1/static/z-d8-themes/orange# cat orange.theme
  15. <?php
  16. /**
  17.  * Implements template_preprocess_page.
  18.  */
  19. function orange_preprocess_comment(&$variables) {
  20.  
  21.   $comment = $variables['comment'];
  22.   $owner = $comment->getOwner();
  23.   $roles = $owner->getRoles();
  24.  
  25.   // Let's pop the roles array to only
  26.   // get the last (highest) role of all.
  27.   $role = array_pop($roles);
  28.  
  29.   $variables['attributes']['class'][] = 'author-' . $role;
  30. }
  31.  
  32. function orange_preprocess_page(&$variables) {
  33.   if ($variables['is_front']) {
  34.     $variables['#attached']['library'][] = 'orange/test';
  35.   }
  36. }
  37. $:/data/disk/o1/static/z-d8-themes/orange# cd templates
  38. $:/data/disk/o1/static/z-d8-themes/orange/templates# ls
  39. comment.html.twig
  40. $:/data/disk/o1/static/z-d8-themes/orange/templates# cat comment.html.twig
  41. {#
  42. /**
  43.  * @file
  44.  * Bartik's theme implementation for comments.
  45.  *
  46.  * Available variables:
  47.  * - author: Comment author. Can be a link or plain text.
  48.  * - content: The content-related items for the comment display. Use
  49.  *   {{ content }} to print them all, or print a subset such as
  50.  *   {{ content.field_example }}. Use the following code to temporarily suppress
  51.  *   the printing of a given child element:
  52.  *   @code
  53.  *   {{ content|without('field_example') }}
  54.  *   @endcode
  55.  * - created: Formatted date and time for when the comment was created.
  56.  *   Preprocess functions can reformat it by calling format_date() with the
  57.  *   desired parameters on the 'comment.created' variable.
  58.  * - changed: Formatted date and time for when the comment was last changed.
  59.  *   Preprocess functions can reformat it by calling format_date() with the
  60.  *   desired parameters on the 'comment.changed' variable.
  61.  * - permalink: Comment permalink.
  62.  * - submitted: Submission information created from author and created
  63.  *   during template_preprocess_comment().
  64.  * - user_picture: The comment author's profile picture.
  65.  * - status: Comment status. Possible values are:
  66.  *   unpublished, published, or preview.
  67.  * - title: Comment title, linked to the comment.
  68.  * - attributes: HTML attributes for the containing element.
  69.  *   The attributes.class may contain one or more of the following classes:
  70.  *   - comment: The current template type; e.g., 'theming hook'.
  71.  *   - by-anonymous: Comment by an unregistered user.
  72.  *   - by-{entity-type}-author: Comment by the author of the parent entity,
  73.  *     eg. by-node-author.
  74.  *   - preview: When previewing a new or edited comment.
  75.  *   The following applies only to viewers who are registered users:
  76.  *   - unpublished: An unpublished comment visible only to administrators.
  77.  * - title_prefix: Additional output populated by modules, intended to be
  78.  *   displayed in front of the main title tag that appears in the template.
  79.  * - title_suffix: Additional output populated by modules, intended to be
  80.  *   displayed after the main title tag that appears in the template.
  81.  * - title_attributes: Same as attributes, except applied to the main title
  82.  *   tag that appears in the template.
  83.  * - content_attributes: List of classes for the styling of the comment content.
  84.  * - threaded: A flag indicating whether the comments are threaded or not.
  85.  *
  86.  * These variables are provided to give context about the parent comment (if
  87.  * any):
  88.  * - comment_parent: Full parent comment entity (if any).
  89.  * - parent_author: Equivalent to author for the parent comment.
  90.  * - parent_created: Equivalent to created for the parent comment.
  91.  * - parent_changed: Equivalent to changed for the parent comment.
  92.  * - parent_title: Equivalent to title for the parent comment.
  93.  * - parent_permalink: Equivalent to permalink for the parent comment.
  94.  * - parent: A text string of parent comment submission information created from
  95.  *   'parent_author' and 'parent_created' during template_preprocess_comment().
  96.  *   This information is presented to help screen readers follow lengthy
  97.  *   discussion threads. You can hide this from sighted users using the class
  98.  *   visually-hidden.
  99.  *
  100.  * These two variables are provided for context:
  101.  * - comment: Full comment object.
  102.  * - entity: Entity the comments are attached to.
  103.  *
  104.  * @see template_preprocess_comment()
  105.  */
  106. #}
  107. {%
  108.   set classes = [
  109.     'comment',
  110.     'js-comment',
  111.     status != 'published' ? 'comment--' ~ status,
  112.     comment.owner.anonymous ? 'by-anonymous',
  113.     author_id and author_id == commented_entity.getOwnerId() ? 'by-' ~ commented_entity.getEntityTypeId() ~ '-author',
  114.     'clearfix',
  115.   ]
  116. %}
  117. <article role="article"{{ attributes.addClass(classes)|without('role') }}>
  118.   {#
  119.     Hide the "new" indicator by default, let a piece of JavaScript ask the
  120.     server which comments are new for the user. Rendering the final "new"
  121.     indicator here would break the render cache.
  122.   #}
  123.   <span class="hidden" data-comment-timestamp="{{ new_indicator_timestamp }}"></span>
  124.  
  125.   <footer class="comment__meta">
  126.     {{ user_picture }}
  127.     <p class="comment__author">{{ author }}</p>
  128.     <p class="comment__time">{{ created }}</p>
  129.     <p class="comment__permalink">{{ permalink }}</p>
  130.     {#
  131.       Indicate the semantic relationship between parent and child comments
  132.       for accessibility. The list is difficult to navigate in a screen
  133.       reader without this information.
  134.     #}
  135.     {% if parent %}
  136.       <p class="visually-hidden">{{ parent }}</p>
  137.     {% endif %}
  138.   </footer>
  139.  
  140.   <div{{ content_attributes.addClass('comment__content') }}>
  141.     {% if title %}
  142.       {{ title_prefix }}
  143.       <h3{{ title_attributes }}>{{ title }}</h3>
  144.       {{ title_suffix }}
  145.     {% endif %}
  146.     {{ content }}
  147.   </div>
  148. </article>
  149. $:/data/disk/o1/static/z-d8-themes/orange/templates#
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top