Skip to content

Instantly share code, notes, and snippets.

View jnowland's full-sized avatar

James Nowland jnowland

View GitHub Profile
@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 / 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;
}
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;
}
}
});
<?php
return array(
'*' => array(
'tablePrefix' => 'craft',
),
'dev' => array(
'server' => 'localhost',
'user' => 'root',
'password' => '',
@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 }}"/>

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 / 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.
@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 / map-division.scss
Last active August 29, 2015 14:01
Attempting to set a negative margin-top of half height using sass maps. The units returning don't appear to be a string or integer.
// Generated from spritesmith via gulp
$sprites: (
arrow-right-blue-withShadow: (
x: 0px,
y: 114px,
offset_x: 0px,
offset_y: -114px,
width: 13px,
height: 19px,
@jnowland
jnowland / typekit-ckeditor.js
Created April 10, 2014 06:42
Enables Typekit to be embed inside of CK Editor Field.
var typkitID = 'XXXXXX';
CKEDITOR.on(
'instanceReady',
function(ev) {
var $script = document.createElement('script'),
$editor_instance = CKEDITOR.instances[ev.editor.name];
$script.src = '//use.typekit.com/'+typkitID+'.js';
$script.onload = function() {