1

My site is with Drupal 8, I have a content type "Article" with a body field.

I copied the twig node.html.twig file into my theme.

If I put the following code, the description is displayed:

{{ content.field_article_description }}

The parameter of the display of the field, allows to choose the number of characters. But he stops at the first sentence, cuts the word and does not display the elipse (...).

enter image description here

I want the description to be cut to 150 characters right after the word (I do not want the last nmot to be cut) and I want to add at the end an elipse (...).

I want the field to be displayed in plain text (without html tags).

Is it possible to add parameters to the description field with twig ?

Can you help me ?

1

Check out Smart Trim module.

Smart Trim implements a new field formatter for textfields (text, text_long, and text_with_summary, if you want to get technical) that improves upon the "Summary or Trimmed" formatter built into Drupal 7.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy