Hello,

I created a view and included a Title, Body and Teaser Thumbnail. Everything is working fine its just that I want to strip all the HTML tags in this selected Body, in other words only the plain text.

Please guide.

Thanks and Regards

Comments

dadofgage’s picture

Have you happen to have found a solution for this? I am wanting to do the same thing.

I am learning’s picture

I did it in the template itself, may not be the right solution for you.
In my template, inside a div, I wrote:
print substr(strip_tags($my_view_block_name), 0, 250);

So as you can notice it will display 250 characters and before that it strips the HTML from the view content. $my_view_block_name is the name of the view block.

Rajeev

mollydustin’s picture

If you're using Views, the easiest way to do this without any extra modules is to use the built-in "Rewrite results" feature. Under the field settings, just check "Rewrite the output of this field" and then look for the "Strip HTML tags" option in the configuration. It’s super handy because you can also whitelist specific tags if you want to keep things like line breaks or bold text. When I’m testing out how the content will actually look once the tags are gone (especially with messy imported data), I usually just paste a snippet into this HTML stripper to double-check the formatting. It’s a bit faster than clearing the Drupal cache every time you want to see a change.

henrywalker’s picture

You can strip HTML tags in views by using built-in helpers or plain text rendering. In most frameworks, functions like strip_tags() or similar utilities remove HTML safely before displaying content. It helps keep the output clean and prevents unwanted formatting.