Search
Site Essentials for Statamic

Site Essentials for Statamic

se_radius_excerpt Modifier

The se_radius_excerpt modifier may be used to create an excerpt of the provided text. It will attempt to include the text on either side of the search string, up to a certain character count or radius.

By default, the se_radius_excerpt modifier will use the GET q parameter as its search value, but can be overridden. This behavior makes it ideal for rendering search result pages.

1{{ the_loop }}
2 {{ text_content | se_radius_excerpt /}}
3{{ /the_loop }}

The search string can be changed by suppling a string value as the first argument:

1{{ the_loop }}
2 {{ text_content | se_radius_excerpt('search string') /}}
3{{ /the_loop }}

The number of characters it should attempt to include on each side of the search string defaults to 250. This can be changed by supplying a second argument:

1{{# The quick brown fox jumps over the lazy dog #}}
2{{ "The quick brown fox jumps over the lazy dog" | se_radius_excerpt('fox') /}}
3 
4{{# …ick brown fox jumps ove… #}}
5{{ "The quick brown fox jumps over the lazy dog" | se_radius_excerpt('fox', 10) /}}

The omission characters, which defaults to may be changed by supplying a third argument:

1{{# !!!ick brown fox jumps ove!!! #}}
2{{ "The quick brown fox jumps over the lazy dog" | se_radius_excerpt('fox', 10, '!!!') /}}

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.