Silverstripe Version:4*
I need to customize the BlogPost summaries:
- Limit to 350 characters or 30 words
- Preserve HTML (links, colors,…) after limit
- Render HTML in template
I don’t suppose anyone has had to do that yet?
BlogPostExtension.php
class BlogPostExtension extends DataExtension {
private $CustomExcerpt;
public function CustomExcerpt() {
// TODO: Limit content and preserve HTML
return $this->owner->Content;
}
}
BlogPostSummaries.ss
<% loop $AllBlogPosts %>
...
<p class="l-card_excerpt">$CustomExcerpt</p> // How to render the HTML??
...
<% end_loop %>
The problem now is that the HTML is not rendererd.
Result is not rendered:
<b>Some text</b><br>..
What do I need to do to render the HTML?