Here are a few common tasks you might do in your templates, as they would be written in ExpressionEngine vs. Craft CMS.
This file contains hidden or 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
title: Fieldset Kitchen Sink | |
fields: | |
status: | |
type: status | |
_template: | |
type: templates |
This file contains hidden or 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
<div id="payment-errors"> | |
{{ bison:checkout_form_errors }} | |
{{ if missing }} | |
<p>You are missing the following fields.</p> | |
<ul> | |
{{ missing }} | |
<li>The {{ field_label }} field {{ message }}</li> | |
{{ /missing }} | |
</ul> | |
{{ endif }} |
This file contains hidden or 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 | |
// Get the entry | |
$entry = craft()->entries->getEntryById(100); | |
// Convert the existing data to what it would look like in POST | |
$matrixData = array(); | |
foreach ($entry->matrixField as $block) | |
{ |
This file contains hidden or 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
module.exports = function(grunt) { | |
grunt.initConfig({ | |
concat: { | |
// js stuff | |
}, | |
uglify: { | |
// more js stuff |
This file contains hidden or 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
<!-- | |
A template for raven stuff. | |
Display this at a URL like /contact-form for example | |
Exclude this URL from html_caching | |
Make this form look/act like it was part of the parent page. | |
The contents of #raven will be injected into it. | |
--> |
This file contains hidden or 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 getSrcSet(image, sizes, upscale) %} | |
{%- spaceless %} | |
{% set sizesOut = [] %} | |
{% set allowScaleLarger = upscale | default(false) %} | |
{# loop over sizes parameter and generate transforms #} | |
{% for size in sizes %} | |
{%- spaceless %} | |
{% set currentTransform = {} %} | |
This is simple, clear and concise contract that I use for general creative and technical projects. It's based largely upon Brendan Dawe's excellent open-source design contract, but has been modified to contain more appropriate terminology for my field, and now contains sections pertaining to source code, ongoing support, NDA's etc.
Please feel free to fork, modify, distribute and use this document as you wish - and please please do use it. Do not start work without a contract, ever. Additionally: DO NOT START WORK WITHOUT A CONTRACT, EVER.
Dan Hett ("Developer", "me", "I")
[CLIENT NAME] ("Client", "you")
This file contains hidden or 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
{# ================================================================== #} | |
{# Responsive Image Macro | |
{# ================================================================== #} | |
{# | |
Macro to centralize the markup and config for responsive images. | |
Based on an article by Marion Newlevant (@marionnewlevant) and | |
adapted for the Lazysizes plugin. Read more: | |
https://straightupcraft.com/articles/responsive-images-with-twig-macros |
This file contains hidden or 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
{# How to handle querystring filters in a single Twig template. #} | |
{# Baseline entries/categories criteria. #} | |
{# Set any criteria here that will be relevant regardless of filters. #} | |
{# Section name can be array if you need to fetch from more than one section. #} | |
{% set criteria = { | |
section: ['sectionName'], | |
order: 'postDate desc', | |
limit: 9 | |
} %} |