Read more for long sentences ...

0
Hi guys, Anyone know how to make this happened? How to make a long sentences become like this? When we input a long senteces, it will show … when reach limit.
asked
2 answers
2

The forum as shown in your screenshot shows a string attribute containing html, which is why they’re using the CKEditor viewer widget. It has a cut off feature.

You could also use the Show More/less widget to cut off regular string attributes at a specified length.

Or, if you want to show text on one line only, you could use CSS. Give the text a class like ‘truncate’ and add rules in your Sass files like

.truncate {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 99%;
}

 

answered
0

You can also do it “manually”, let’s says you have an entity with an attribute Comment and another attribute CommentTruncated.

In the microflow of the save of the attribute Comment, you will check it’s length, if it’s above 200 (for example), you will put the first 200 characters of the Comment in the attribute CommentTruncated and add “...” at the end of the sentence, if it’s below 200 characters you will just put the value of Comment inside CommentTruncated.

Then you just have to display the CommentTruncated instead of the Comment.

answered