Skip to content

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

License

Notifications You must be signed in to change notification settings

dsparks83/statamic-word-truncate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages