View searchit_category_filter.twig
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 handle = 'category_handle' %} | |
{% for category in craft.categories.group(handle).all() %} | |
{% set line = '' %} | |
{% set depth = category.getAncestors()|length %} | |
{% for number in range(0, depth) %} | |
{% set line = line ~ '=' %} | |
{% endfor %} | |
{{ ({ | |
filter: { | |
relatedTo: category.id |
View Twig truncate macro
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 truncate(text, limit, append) %} | |
{# settings #} | |
{% set suffix = append|default('...') %} | |
{% set punctuation = ['.',',','-',':',';'] %} | |
{# logic #} | |
{% set array = text|split(' ') %} | |
{% set arrayTruncated = array|slice(0, limit) %} | |
{% set string = arrayTruncated|join(' ') %} | |
{% if limit and array|length > limit %} | |
{% for mark in punctuation %} |
View gist:a7e56ea2713ea5d0fab451c3e282ecfd
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
var gulp = require('gulp'); | |
var concat = require('gulp-concat'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var sass = require('gulp-sass'); | |
var browserSync = require('browser-sync').create(); | |
const notifier = require('node-notifier'); | |
gulp.task('dev', ['sass:development', 'watch:development', 'browser-sync']); | |
gulp.task('default', ['dev']); |
View Craft CMS - URL macro
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 #} | |
{% macro url(routeName, tokens) %} | |
{% spaceless %} | |
{% set keyword = 'name' %} | |
{% set routeString = null %} | |
{% for route, routeSettings in craft.app.routes.getConfigFileRoutes %} | |
{% if routeSettings[keyword] is defined and routeSettings[keyword] == routeName %} | |
{% set routeString = route %} | |
{% endif %} |
View quick_edit.twig
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
{# v4 #} | |
{% if currentUser and currentUser.can('accessCp') and not craft.app.request.isLivePreview %} | |
{% set element = element|default(craft.app.urlManager.matchedElement) %} | |
{% if element and element.isEditable %} | |
{% set editLink = element.getCpEditUrl() %} | |
{% if element.draftId is defined and element.draftId is not null %} | |
{% set editLink = editLink ~ '&draftId='~ element.draftId %} | |
{% endif %} | |
{% set editText = 'edit'|t %} | |
{% else %} |
View app.php
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
<?php | |
return [ | |
'components' => [ | |
'mailer' => function() { | |
$settings = \craft\helpers\App::mailSettings(); | |
$settings->transportType = \craft\mail\transportadapters\Smtp::class; | |
$settings->transportSettings = [ | |
'useAuthentication' => true, | |
'host' => getenv('SMTP_HOST'), | |
'port' => getenv('SMTP_PORT'), |
View feed.rss
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
{% spaceless %} | |
{# settings #} | |
{% set title = siteName %} | |
{% set channelDescription = 'description' %} | |
{% set descriptionHandle = 'intro' %} | |
{% set items = craft.entries.section('articles').limit(50) %} | |
{# feed #} | |
{% if craft.app.request.segments|last == _self %} | |
<?xml version="1.0" encoding="UTF-8"?> | |
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> |
View element-api.php
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
<?php | |
use craft\elements\Entry; | |
return [ | |
'endpoints' => [ | |
'search.json' => function() { | |
// settings | |
$section_handle = 'articles'; | |
$phrase = Craft::$app->request->getParam('query'); |
OlderNewer