The notification block is difficult to customize

Created on 26 May 2018, almost 7 years ago
Updated 7 December 2024, 4 months ago

The notification block is difficult to customize. It would be nice to take the model of "Drupal Commerce 2".

Here we have {{count_text}} to display the number of items. This adds plain text without markup.

With "Private Message" the number of elements is added by a class and adds markup.

Drupal shopping cart template without modification:

<div{{ attributes}}>
  <div class="cart-block--summary">
    <a class="cart-block--link__expand" href="{{ url }}">
      <span class="cart-block--summary__icon">{{ icon }}</span>
      <span class="cart-block--summary__count">{{ count_text }}</span>
    </a>
  </div>
  {% if content %}
  <div class="cart-block--contents">
    <div class="cart-block--contents__inner">
      <div class="cart-block--contents__items">
        {{ content }}
      </div>
      <div class="cart-block--contents__links">
        {{ links }}
      </div>
    </div>
  </div>
  {% endif %}
</div>

Now I do not want to display the item number, but simply change the icon when the cart contains a product.
Drupal shopping cart template with modification:

<div{{ attributes }}>
  <div class="cart-block--summary">
    <a class="cart-block--link__expand" href="{{ url }}">

      <div class="icon-cart">
        <span class="fa-layers fa-3x">
          <i class="far fa-circle"></i>
          <i class="fas fa-shopping-basket" data-fa-transform="shrink-6"></i>
        </span>
      </div>

      {% if count > 0 %}
        <div class="icon-cart-alert">
          <span class="fa-layers fa-3x">
            <i class="fas fa-circle"></i>
            <i class="fas fa-shopping-basket fa-inverse" data-fa-transform="shrink-6"></i>
          </span>
        </div>
      {% endif %}

    </a>
  </div>
  {% if content %}
  <div class="cart-block--contents">
    <div class="cart-block--contents__inner">
      <div class="cart-block--contents__items">
        {{ content }}
      </div>
      <div class="cart-block--contents__links">
        {{ links }}
      </div>
    </div>
  </div>
  {% endif %}
</div>

I want to have the same thing with "Private Message". Simply change the logo when there is a message.

📌 Task
Status

Active

Version

4.0

Component

User interface

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.

  • 🇷🇴Romania claudiu.cristea Arad 🇷🇴

    This is a legit request. I see several issue:

    • The class (stored in unread_notification_class) should be conditionally added. If it comes empty should not be added.
    • The URL should be passed as var along with from private_message_page_link.
    • The link should be constructed in Twig from the new UR: and new_items_count variables
    • I think unread_notification_class is opinionated (the 99+ thingie) and should be deprecated in 4.x and dripped in 5.x
Production build 0.71.5 2024