CMS Development

Marius
Participante | Parceiro Platinum
Participante | Parceiro Platinum

Limit text to display on blog listing page

resolver

Hi, in the blog list page, i want to limit the text to display in each blog post here. It can be easily done with post with  TEXT ONLY content with css like this:

 

.post-body-list {
height: 300px;
text-overflow: ellipsis;
overflow: hidden;
}

 

However, sometime the post content can also contain  html elements  like <p>, <div> etc ( user can copy the content of other website and paste them to thier blog post). Is there a way to limit the text to display in this case?

0 Avaliação positiva
1 Solução aceita
ndwilliams3
Solução
Conselheiro(a) de destaque

Limit text to display on blog listing page

resolver

in Design Manager on your blog listing template you can control the post summary and use filters to change the output.

 

Here's some options that may work for you.

 

Strip HTML tags

{{ content.post_list_content|striptags }}

strip HTML tags and trunicate

 {{ content.post_list_content|striptags|truncate(120, breakword=False, end='...')}}

 Trunicate and keep HTML tags intact

  {{ content.post_list_content|truncatehtml(200, '...', false)}}

Exibir solução no post original

1 Resposta 1
ndwilliams3
Solução
Conselheiro(a) de destaque

Limit text to display on blog listing page

resolver

in Design Manager on your blog listing template you can control the post summary and use filters to change the output.

 

Here's some options that may work for you.

 

Strip HTML tags

{{ content.post_list_content|striptags }}

strip HTML tags and trunicate

 {{ content.post_list_content|striptags|truncate(120, breakword=False, end='...')}}

 Trunicate and keep HTML tags intact

  {{ content.post_list_content|truncatehtml(200, '...', false)}}