0

Is there an easy way to always show the "read more..." link when text is trimmed in a view?

Was looking for an "Always show read-more link" option for cases when the text is not long enough to be trimmed, but there is none unfortunately. :(

Any suggestions?

Thanks!

View field options - read-more link

2
  1. Add the trim limit for the content field what you want.
  2. Add the link to content field in the view and put the display content.

enter image description here

enter image description here

| improve this answer | |
  • Thanks for your reply Karuna. Do you know what the machine name is for "Link to Content"? I ask because I am providing a customized template for the view by overriding views-view-fields.html.twig and need to figure out how to display the "Link to Content" field. I tried {{ link_to_content }} and {{ fields.field_link_to_content.content }}, but neither worked. Any ideas? Thanks again! – kvjava1 Feb 17 '17 at 18:09
  • Found out that this works: {{ fields.view_node.content }}, but running into a formatting issue now. When content is stripped and the 'Read more' is added, the content's closing </p> tag comes after the 'Read more' link. However, if content is not stripped, then the content's closing </p> tag comes before the 'Read more' link, which forces it to appear on a separate line. :( Trying to figure out a solution... – kvjava1 Feb 17 '17 at 18:51
  • Accomplished what I was trying to do with the following in views-view-fields.html.twig: <div class="description">{{ fields.field_event_description.content|striptags }} {{ fields.view_node.content }}</div> The 'striptags' filter strips the offending <p> tags (and all other HTML tags, unfortunately), but for this short listing view, it is not significant, as most descriptions do not contain (much) markup in the short, truncated part that is being displayed. Could also use replace. Thanks again for your help with the 'Link to Content' field suggestion in the View configuration!!! – kvjava1 Feb 17 '17 at 19:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.