Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

README.md

Statamic word based truncate modifier

Move Statamic's word based truncation to a modifier, it will also close any open tags in the generated excerpt. Copy the folder word_truncate folder to your _add_ons folder. Apply like any other filter with a colon to indicate the number of words you'd like in the excerpt.

{{ content|word_truncate:75 }}

That will produce an excerpt 75 words in length.

You can change your ending with a second parameter

{{ content|word_truncate:75:more }}

However be careful as it's likely to trigger issues if you put much more than a text string in. If you need something more then edit this bit of code at the top of the plugin

if(isset($parameters[1]) && $parameters[1] != "") $ending = $parameters[1]; else $ending = "…";

Replace … with your preferred ending.

About

Move Statamic's word based truncation to a modifier. It will also close open tags in the excerpt.

Resources

License

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.