Same as this D7 request here, it would be great to have the option of a maxlength with ellipsis for the title (and other?) segments of the breadcrumb.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

W01F created an issue. See original summary.

greg boggs’s picture

Great idea!

w01f’s picture

This is how I solved it via a custom twig template - breadcrumb.html.twig

{% if breadcrumb %}
  <nav class="breadcrumbs" role="navigation" aria-labelledby="system-breadcrumb">
    <h2 id="system-breadcrumb">{{ 'Breadcrumb'|t }}</h2>
    <ol class="grid-row grid-gap-md">
      {% for item in breadcrumb %}
        <li class="breadcrumbs--item grid-col-auto">
          {% if item.url %}
            <a href="{{ item.url }}">
              {{ item.text|striptags|length > 35 ? item.text|slice(0, 35) ~ '...' : item.text }}
            </a>
          {% else %}
            {{ item.text|striptags|length > 35 ? item.text|slice(0, 35) ~ '...' : item.text }}
          {% endif %}
        </li>
      {% endfor %}
    </ol>
  </nav>
{% endif %}
w01f’s picture

Updated the code - had too many |striptags in there that was causing special characters to output incorrectly as per https://www.drupal.org/project/easy_breadcrumb/issues/3190151

DeaOm made their first commit to this issue’s fork.

deaom’s picture

Status: Active » Needs review

The truncate title functionality was added based on the mentioned/linked D7 one. Tested it locally and for me it seems to be working, but there might be things I have missed, so a review/test is very welcomed.

extect’s picture

Status: Needs review » Needs work

Would love to see this feature.

I updated an existing test site with this. It throws the following errors on saving the easy_breadcrumb admin page:

InvalidArgumentException: $string ("100") must be a string. in Drupal\Core\StringTranslation\TranslatableMarkup->__construct() (line 132 of core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php).

Guess we need a hook_update to ensure existing sites get a db update.

greg boggs’s picture

Hrm, not seeing the bug in the merge request right now, but it's been a long day. fixes from others welcome!

i-trokhanenko’s picture

Status: Needs work » Needs review
i-trokhanenko’s picture

Status: Needs review » Reviewed & tested by the community

Works well for me, thanks!
+1 RTBC

renatog’s picture

it really makes sense. +1 to it

Neslee Canil Pinto made their first commit to this issue’s fork.

neslee canil pinto’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.