Skip to content

Instantly share code, notes, and snippets.

View jnowland's full-sized avatar

James Nowland jnowland

View GitHub Profile
@jnowland
jnowland / display-categories.twig
Last active February 28, 2017 16:53
Craft Snippets
{# Shows all categories in the news group #}
{% set categories = craft.categories.group('news') %}
<ul>
{% nav category in categories %}
<li>
<a title="{{ category.title }}" href="{{ category.url }}">{{ category.title }}</a>
{# Output a nested <ul> if this category has any children #}
{% ifchildren %}
<ul>{% children %}</ul>
@jnowland
jnowland / SassMeister-input.scss
Created June 6, 2014 10:28
Generated by SassMeister.com.
// ----
// Sass (v3.3.8)
// Compass (v1.0.0.alpha.18)
// ----
/* Note: The css selectors
The 'Grey' changes from UK to USA spelling
The Primary colours are all lowercae and not camelcase
This is because keys are don't have to be strings.

Templating in EE vs. Craft

Lots of people have asked, so here are a few common tasks you might do in your templates, as they would be written in ExpressionEngine vs. Craft.

Table of Contents

  1. Comments{{ cycle(['odd','even'], loop.index0 }}

  2. Conditionals

@jnowland
jnowland / _layout.html
Last active August 29, 2015 14:03
Open Search in Craft
{# Open Search #}
<link rel="search" type="application/opensearchdescription+xml" href="/news/opensearch.xml" title="Search {{ siteName }}"/>
<?php
return array(
'*' => array(
'tablePrefix' => 'craft',
),
'dev' => array(
'server' => 'localhost',
'user' => 'root',
'password' => '',
Modernizr.addTest('retina', function(){
if (window.matchMedia) {
var mq = window.matchMedia("only screen and (-moz-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3), only screen and (min-resolution: 1.3dppx)");
if(mq && mq.matches) {
return true;
}
}
});
@jnowland
jnowland / avoid-drunkextends-output.css
Last active August 29, 2015 14:06
Extends can be very bad.
/*
Using silent class
*/
.Button, .Random {
background: red;
}
div .Button {
color: red;
}
@jnowland
jnowland / SassMeister-input.scss
Created September 19, 2014 08:05
Generated by SassMeister.com.
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
/*
Using silent class
*/
%background {
@jnowland
jnowland / preferences.sublime-settings
Created October 19, 2014 23:35
Sublime Text 2 Preferences
{
"bold_folder_labels": true,
"detect_indentation": true,
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": true,
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
# Ask for the administrator password upfront
sudo -v
# mkdir -p ~/Sites/Work/Clients
# mkdir -p ~/Sites/Work/Internal
# mkdir -p ~/Sites/Personal
# mkdir -p ~/Downloads/Torrents
mkdir -p /Volumes/Sites/Work/Clients
mkdir -p /Volumes/Sites/Work/Internal