This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro emailLinks(text, class) %} | |
{# v1 #} | |
{% spaceless %} | |
{% set text = text|replace('/([a-zA-Z0-9_.+-]+)+@([a-zA-Z0-9-]+.[a-zA-Z]+)/', '<a ' ~ (class ? 'class="' ~ class ~ '" ') ~ 'href="mailto:'~ '\\1@\\2' ~'">'~ '\\1@\\2' ~'</a>') %} | |
{{text|raw}} | |
{% endspaceless %} | |
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# v3 #} | |
{# http://craftsnippets.com/articles/ellipsis-pagination-component-for-craft-cms #} | |
{# requires pageInfo variable #} | |
{# settings #} | |
{% set neighbours = 1 %} | |
{# symbols #} | |
{% set prev = '❮' %} | |
{% set next = '❯' %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# settings #} | |
{% set info = pageInfo %} | |
{# logic #} | |
{% if info.totalPages > 1 %} | |
<select name="" id="" onchange="document.location.href = this.options[this.selectedIndex].value;"> | |
{% for link in info.getRangeUrls( 1, info.totalPages ) %} | |
<option value="{{link}}" {{info.currentPage == loop.index ? 'selected="selected"'}}>{{'page'|t}} {{loop.index}}</option> | |
{% endfor %} | |
</select> | |
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set shortname = 'YOUR_WEBSITE_SHORTNAME' %} | |
{% if entry is defined %} | |
<div id="disqus_thread"></div> | |
<script> | |
var disqus_config = function () { | |
this.page.url = '{{entry.url}}'; | |
this.page.identifier = '{{entry.id}}'; | |
this.page.title = '{{entry.title}}'; | |
}; | |
(function() { // DON'T EDIT BELOW THIS LINE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# v2 #} | |
{% if pagination_list is defined %} | |
{% js %} | |
// AJAX REQUEST DATA | |
{% set current_url = craft.request.getRequestUri()|split(craft.request.getPath())[0]~craft.request.getPath() %} | |
{% set ajax_data = { | |
current_url: current_url, | |
pagination_list: pagination_list|hash, | |
pagination_parameters: pagination_parameters ?? null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro responsiveImage(file, sizes, options) %} | |
{# settings #} | |
{% set pixel = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==' %} | |
{# logic #} | |
{% if file is defined and sizes is defined and sizes is iterable %} | |
{% if sizes|first is iterable or sizes|first is null %} | |
{# array of transforms #} | |
<picture class="{{options.class ?? null}}"> | |
{% for media, settings in sizes %} | |
{% set url = settings is not null ? file.getUrl(settings) : pixel %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro phoneNumber(phoneNumber) %} | |
<a href="tel:{{ phoneNumber|replace({'-':'', ' ':'', '.':'', '(':'', ')':''}) }}">{{ phoneNumber }}</a> | |
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro readTime(text) %} | |
{% spaceless %} | |
{# v1 #} | |
{# settings #} | |
{% set wordsPerMinute = 265 %} | |
{% set showLessThanMinute = true %} | |
{# logic #} | |
{% set plaintext = text|striptags|replace({'—': ' ', '–': ' ', '-': ' ', '\n': ' '}) %} | |
{% set words = plaintext|split(' ') %} | |
{% set minutes = ceil(words|length / wordsPerMinute) %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# v2 #} | |
{# http://craftsnippets.com/articles/universal-language-switcher-for-craft-cms #} | |
{# logic #} | |
{% set currentElement = craft.app.urlManager.matchedElement %} | |
{% set sites = craft.app.getSites().getGroupById(currentSite.groupId).getSites() %} | |
{% set switcherLinks = [] %} | |
{% for site in sites if site.baseUrl is not empty %} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# v1 #} | |
{% macro truncateWords(text, length, suffix) %} | |
{% spaceless %} | |
{# settings #} | |
{% set defaultSuffix = '...' %} | |
{# logic #} | |
{% if text and length %} | |
{% set suffix = suffix|default(defaultSuffix) %} | |
{% set text = text|striptags %} | |
{% set text = text|replace('/\\n/', '\n ') %} |