<p> tag showing in the views result when aggregation on

Created on 6 May 2025, 27 days ago

I have a views which I turn the aggregation on, but then the body field showing the

tag in the result, I have checked the "Strip HTML tags" for the body field already, please advise what am I missing and why the

tag showing ? Thank you

💬 Support request
Status

Active

Version

10.4

Component

views.module

Created by

🇬🇧United Kingdom freelylw

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

Comments & Activities

  • Issue created by @freelylw
  • 🇮🇳India hitvikav_

    When using "Use aggregation: Yes" in Views, fields like Body output the raw stored value, so any HTML is shown as escaped entities (e.g., `<p>`). This happens because Views disables field formatters and text processing in aggregation mode.

    Quick fix: Use "Rewrite results" and apply the `|striptags` or `|raw` Twig filter based on your needs:

    * `{{ body|striptags }}` → for clean plain text
    * `{{ body|raw }}` → to render HTML (only if content is trusted)
    * Override the twig file

  • 🇬🇧United Kingdom freelylw

    Thanks, its showing the text "<p>" at the front of the every body text when I apply "{{ body|striptags }}" into the "Override the output of this field with custom text" please advise what do to to fix this ? Thank you

  • 🇮🇳India Ishani Patel

    Hello @freelylw,
    You can try with this {{ body.value|striptags }}
    Because body.value gets the raw text content of the field. body alone might give you a rendered version with tags or wrappers still attached.

    Thank you!

  • 🇮🇳India hitvikav_

    Hi @freelylw,
    If {{ body|striptags }} is not working you can try {{ body__value|raw }} it worked for me
    @ishani patel {{ body.value|striptags }} didn't worked for me i guess we need to use the option present in rewrite result fields for raw value

  • 🇬🇧United Kingdom freelylw

    this one {{ body__value|raw }} works, thank you.

  • {{ body__value|raw }} is insecure.

Production build 0.71.5 2024