More Link on node

Created on 22 August 2024, 3 months ago

Hi all,

One of my node fields has long text so I want to show a trimmed version of the field and let the user to be able to click "more" if they want to see the full text of this field.

So on the node url example.com/node/7 I am using the the "more" link but the link just goes to the same url example.com/node/7 with the "more" link again.

So I guess that smart trim is not meant to be used on a node such as example.com/node/7 ?

💬 Support request
Status

Needs review

Version

2.2

Component

Miscellaneous

Created by

🇬🇧United Kingdom juc1

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

Comments & Activities

  • Issue created by @juc1
  • 🇮🇳India rohitsharma401

    {# Check if the field has content #}
    {% if content.field_long_text %}
    {# Display the trimmed version of the text #}
    {% set trimmed_text = content.field_long_text['#text']|slice(0, 200) %}

    {{ trimmed_text }}
    {% if content.field_long_text['#text']|length > 200 %}
    Read more
    {% endif %}

    {% endif %}

    i think you are trying to do like this , but by this you will be redirecting to the page or node url only where you can get the full content of the page .

    You need to work with JS for showing the whole content in the same page by clicking on the "Read More" button .

  • Status changed to Needs review 3 months ago
  • 🇺🇸United States markie Albuquerque, NM

    This is outside of the scope for the smart_trim module. You are attempting to hide and show. You could do something like print the trimmed text and the full body text in separate divs, hiding the full body. Then when the more link is clicked, it toggles the visibility via JS.

  • 🇬🇧United Kingdom juc1

    ok thanks for your replies.

Production build 0.71.5 2024