This plugin requires Craft CMS 4.0.0 or later.
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require craft-sprokets-helpers/sprokets-helpers
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for sprokets-helpers.
Just some small things to help ease Craft development
- Add expended options in left-hand menu
- Auto-Expand asset folders
Use an entry title or anything else as an html/array id.
Usage:
{% set str = 'Hello 123 - #42' %}
{{str|idString}}
{# outputs 'Hello12342' #}
Convert plain-text fields with line breaks into html. Changes a single line break to <br>
and double line breaks to <p>
Should probably be used with the raw
filter.
Usage:
{% set str %}
test
test1
test2
{% endset %}
{{str|nl2p}}
{# outputs <p>test<br>test1</p><p>test2</p> #}
Link and obfuscate plain-text emails in any chunk of text.
Useage:
{{entry.body|emailObfuscate}}
OR
{% filter emailObfuscate %}
{# Any Content #}
{% endfilter %}
This can be used to over entire chunks of a website, for instance in your layout template:
{% filter emailObfuscate %}
{% block content %}{% endblock %}
{% endfilter %}
Retrieves video info from youtube or vimeo based on a video url.
Usage:
{% set info = getVideoInfo('https://www.youtube.com/watch?v=ue80QwXMRHg') %}
{{dump(info)}}
{#
array (size=5)
'id' => string 'ue80QwXMRHg' (length=11)
'type' => string 'youtube' (length=7)
'embed' => string '<iframe src="https://www.youtube.com/embed/ue80QwXMRHg?rel=0&showinfo=0&color=white&iv_load_policy=3" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>' (length=184)
'hqthumbnail' => string 'https://i1.ytimg.com/vi/ue80QwXMRHg/hqdefault.jpg' (length=49)
'thumbnail' => string 'https://i1.ytimg.com/vi/ue80QwXMRHg/default.jpg' (length=47)
#}