How to use the Message Template ?

Created on 31 May 2019, about 5 years ago
Updated 31 January 2024, 5 months ago

I have Drupal 8 with the Message module.

I created message templates using drupal 8 but I prefer to use TWIG.

In Drupal 8 my code works, but when I put it in TWIG, the tokens do not work.

How to use the Message Template ?

    {#
    /**
     * @file
     * Default theme implementation for message entities.
     *
     * Available variables:
     * - $content: An array of comment items. Use render($content) to print them all, or
     *   print a subset such as render($content['field_example']). Use
     *   hide($content['field_example']) to temporarily suppress the printing of a
     *   given element.
     * - $title: The (sanitized) entity label.
     * - $url: Direct url of the current entity if specified.
     * - $page: Flag for the full page state.
     * - $classes: String of classes that can be used to style contextually through
     *   CSS. It can be manipulated through the variable $classes_array from
     *   preprocess functions. By default the following classes are available, where
     *   the parts enclosed by {} are replaced by the appropriate values:
     *   - entity-{ENTITY_TYPE}
     *   - {ENTITY_TYPE}-{BUNDLE}
     *
     * Other variables:
     * - $classes_array: Array of html class attribute values. It is flattened
     *   into a string within the variable $classes.
     *
     * @see template_preprocess()
     * @see template_preprocess_message()
     * @see template_process()
     */
    #}
    <div{{ attributes }}>
    
    
    
    
    <div class="timeline">
      <div class="timeline-icon">
        <a href="[message:author:url]" title="[message:author:display-name]">
          <img src="[message:author:user_picture:thumbnail]" alt="[message:author:user_picture:alt]">
        </a>
      </div>
      <div class="timeline-content mb-3">
        <div class="card">
          <div class="card-header text-center">
            Nouvelle boutique
          </div>
          <div class="card-body">
            <div class="card-text">
              <h6>par <a href="[message:author:url]" title="[message:author:display-name]">[message:author:display-name]</a>, il y a [message:created:since]</h6>
            </div>
          </div>
          <div class="card-img-top">
            <a href="[message:field_store_reference:entity:url]" title="[message:field_store_reference:entity:name]">
              <img src="[message:field_store_reference:entity:field_personnel_logo:diaporama_lg_50][message:field_store_reference:entity:field_professionnel_logo:diaporama_lg_50]" alt="[message:field_store_reference:entity:field_personnel_logo:alt][message:field_store_reference:entity:field_professionnel_logo:alt]" typeof="Image" class="img-responsive">
            </a>
          </div>
          <div class="card-body">
            <h3 class="card-title mb-0">
              <a href='[message:field_store_reference:entity:url]'>[message:field_store_reference:entity:name]</a>
            </h3>
          </div>
          <div class="card-footer text-center">
            <small class="text-muted"></small>
              <a class="timeline-link" href='[message:field_store_reference:entity:url]'>
                Voir la boutique test
              </a>
            </small>
          </div>
        </div>
      </div>
    </div>
    
    
    
    
    
    
      {{ content }}
    </div>

[![enter image description here][1]][1]

[1]: https://i.stack.imgur.com/Urf2k.png

πŸ’¬ Support request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡«πŸ‡·France zenimagine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024