CMS Development

Marius
参加者 | Platinum Partner
参加者 | Platinum Partner

Limit text to display on blog listing page

解決

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 いいね!
1件の承認済みベストアンサー
ndwilliams3
解決策
キーアドバイザー

Limit text to display on blog listing page

解決

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)}}

元の投稿で解決策を見る

1件の返信
ndwilliams3
解決策
キーアドバイザー

Limit text to display on blog listing page

解決

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)}}