Substr Plugin for Expression Engine
December 24th, 2007 - downloads expression_engine
This is a plugin for expression engine that performs the simple duty of extracting only a part of a string.
This plugin is used to return a portion of an original string between the {exp:substr} tags. This can be used to display the first part of a post or trim any other text as well.
The two arguments start and length, specify the position where the returned string starts, and also how many characters in length after the start position should be returned.
The start and length arguments work identical to the arguments for the PHP function substr()
You can also use negative arguments as well for start or length. You must specify a start if you specify a length.
Display the first 400 characters of an entry
{exp:substr start="0" length="400"}{body}{/exp:substr}
To install the plugin, simply upload the file pi.substr.php to your /system/plugins directory. You can read more about it by going to Admin -> Utilities -> Plugin Manager in the Expression Engine control panel.
Questions / Comments / Suggestions
You can reach me through the contact page if you have any comments, corrections, or suggestions on this article.