Download the PHP package kolaente/statamic-snippet without Composer
On this page you can find all versions of the php package kolaente/statamic-snippet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kolaente/statamic-snippet
More information about kolaente/statamic-snippet
Files in kolaente/statamic-snippet
Package statamic-snippet
Short Description Adds a snippet modifier to statamic.
License MIT
Informations about the package statamic-snippet
Statamic snippet modifier addon
This is a simple statamic addon which adds a snippet
modifier to easily create a text snippet of a given string.
A snippet is an "intelligent substring": It will try to end the snippet at the end of a sentence (after a dot) within a given character boundary. If no sentence ends within the boundary, it will end after the first word in the boundary and add "..." to the end of the snippet. This will avoid having words cut off in the middle after a fixed boundary.
By default, the boundaries are a minimum of 200 and a maximum of 250 characters.
Usage
Use it in your antlers template like so:
This will transform this text:
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
into this:
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
Modifying the boundaries
The first parameter of the modifier is the min length, the second one is the max length.
For example, to create a snippet between 500 and 600 characters: