Awesome Open Source
Awesome Open Source

Craft Utilities

An evolving toolkit for Craft CMS. Rather than building basic feature shims, shortcuts, and customizations into each project, we've decided to extract them into a discrete bundle and make them available publicly.

Documentation will be broken down into each plugin component, as they're implemented.


One stylesheet exists, currently with a single rule. We disable the site's name in the Control Panel when an icon is added.

Twig Extensions


A few proxies for buried or inaccessible Craft methods, and useful PHP methods.


A shortcut for Craft's built-in single-line Markdown parser.


Quick access to array_unique for filtering out duplicates in an array.

truncate($limit = 160)

Crude text truncation, based on the provided character limit . If a sentence is cut off, an ellipses is added. Words are never broken.


A clean way of adding a list of classes to an HTML element, from Twig.

toList($prop = null, $separator = ', ', $separatorLast = null)

Creates a delimited list from the provided array. Accepts a nested property to pull from the constituent objects or arrays.


Pluck a property from an array of arrays or objects. Subject to failure if you have a mixed dataset, but it will gracefully handle instances of ElementCriteriaModel. Useful for situations where you want grab the same value from a number of objects and output them in a terse way:

<button data-related-ids="{{ entry.relationField | pluck('id') | json_encode }}">Activate Many Items</button>


Unescapes text with encoded HTML entities. Useful in combination with Twig's built-in raw filter to output HTML from a trusted third party's API that is double-escaped in a JSON response.


Takes an array and splits it into $n sub-arrays. For example, [1, 2, 3, 4, 5, 6] split intoGroups(2) would produce an object like [[1, 2, 3], [4, 5, 6]]. This is useful for balancing items into multiple columns.



Unfortunately, PHP makes no fundamental distinction between associative and sequential arrays. This attempts to determine if an array is associative or not, by checking whether a new array of only the original's values is identical

{% if ['A', 'B', 'C'] is sequentialArray %}
{% endif %}

{% if { one: 'Do', two: 'Re', three: 'Mi' } is sequentialArray %}
{% endif %}


A few bits are exposed to Twig templates, via craft.utils.methodName. Check out variables/UtilsVariable.php for the full list of methods.


Alternatives To Craft Utils
Select To Compare

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Php (285,915
Bundle (32,631
Array (24,633
Cms (13,989
Twig (3,363
Craft Plugin (411