Last Updated: February 25, 2016
·
520
· maciejzgadzaj

Text trim

If you have Views' module installed, you can use its <a href="http://api.drupalize.me/api/drupal/function/views_trim_text/7">viewstrimtext()</code></a> function to programmatically trim field value (or any other text for that matter) to a specified length from your code.

Usage: viewstrimtext($alter, $value)</code>

<b>$alter:</b>

<ul>
<li><b>maxlength:</b> Maximum lenght of the string, the rest gets truncated.</li>
<li><b>word
boundary:</b> Trim only on a word boundary.</li>
<li><b>ellipsis:</b> Show an ellipsis (...) at the end of the trimmed string.</li>
<li><b>html:</b> Take sure that the html is correct.</li>
</ul>