Jump to content

Strip_tags not working?

Featured Replies

Posted

I might have something wrong here. I'm trying to strip the HTML from a blog article and only show 200 characters. It seems to work but I get strange characters. What did I do wrong?

          {{$trimmedValue = strip_tags($entry->content()|raw, "<p><div><span><br><hr><b><i><em><strong><img>"); }}
          {{$trimmedValue = substr($trimmedValue, 0, 200);  }}
          {$trimmedValue} <a href="{$entry->url()}">Read More</a>

screenhtml.png

Not sure why you have $entry->content()|rawraw is usually used with the templates.

Try taking the |raw out and see if that doesn't fix the problem.

  • Author
22 hours ago, Hulu said:

Not sure why you have $entry->content()|rawraw is usually used with the templates.

Try taking the |raw out and see if that doesn't fix the problem.

Thanks. Removing the raw did correct the issue. Not fully understanding why it worked. The raw produced all the content in raw format, including the HTML tags.

  • 6 months later...

Was facing the same problem.

The reason why |raw actaully breaks it is because if you execute pure PHP this runs outside the IPS code framework for template output

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.