Streaming live at 10am (PST)

Is it possible to truncate cms content?


#1

Hi there,

Is it possible to have text entered into the CMS be truncated once it's added to the page?

For example I have a field for the client to add in a description of their services and I want to use the first 100 characters of that field as the snippet text on the directory page of their website.

Thanks


Shorten (Truncate) Text Length with "..."
Blog Post with varying title length not causing my posts to not line up!
#2

You can use custom code and text-overflow: ellipsis which will truncate the text when it overflows a box, and place an ellipsis character after it (...)

Typical use case:

.truncate {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

However, the good practice is to have an extra field with a specifically written teaser text, and that field in the collection will be limited to 100 characters. Better for SEO too.