Truncate?

Permalink Browser Info Environment
Is there a way to include a field in the template that is truncated? For instance, if I have a description field and I want the full field to appear in the details page, but only the first 300 characters or so to appear in the list page. Is there a way to get part of the contents of that field?

Thanks

Type: Discussion
Status: New
Metaglyphics
View Replies: View Best Answer
jgarcia replied on at Permalink Best Answer Reply
jgarcia
Yep. Like this:

<field name="Whatever" maxlength="300" />


Or you can specify how many words, using:

<field name="Whatever" maxlength="10 words" />
Metaglyphics replied on at Permalink Reply
Metaglyphics
So simple, thanks!
tobyme replied on at Permalink Reply
tobyme
Hi there -

If I am trying to truncate the length of a description in the page list I currently have:

<?php
if(!$controller->truncateSummaries){
echo $cobj->getCollectionDescription();
}else{
echo $textHelper->shorten($cobj->getCollectionDescription(),$controller->truncateWords);
}
?>

This then uses the controller set in the page list block to control the number of Characters after which it is truncated. How can I change this to be words, as currently it just cuts off words in the middle and I need to change ti to complete a word before cutting.

Any ideas? (I have looked in the c5 api docs I could find but cant see how I would do this)

Cheers
jgarcia replied on at Permalink Reply
jgarcia
I don't know...I'm using a custom function to do this within Data Display. I'm not sure how C5's helper function works.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.