Skip to content

Instantly share code, notes, and snippets.

View jnowland's full-sized avatar

James Nowland jnowland

View GitHub Profile

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
  2. Conditionals
  3. Loops
@jnowland
jnowland / Separator-1.scss
Last active December 31, 2015 16:48
Modifiers and BEM Question.
// method does not set a default.
.Separator{
}
.Separator--1{
border-style: dashed;
border-color: $colour--Neutral600;
border-width: 0 0 1px 0;
}
@jnowland
jnowland / count.js
Last active December 24, 2015 06:49
DISQUS comment count code uncompressed.
var DISQUSWIDGETS, disqus_domain, disqus_shortname;
typeof DISQUSWIDGETS == "undefined" && (DISQUSWIDGETS = function () {
var d = {}, m = document.getElementsByTagName("HEAD")[0] || document.body,
n = 0,
f = {}, j = {
identifier: 1,
url: 2,
slug: 3
};
d.domain = "disqus.com";
@jnowland
jnowland / spacing.scss
Last active December 21, 2015 22:09
Spacing Class
// Generate inline class names for your elements
//
// <div class="actions u-inset-vert-S">
// <button type="submit">Totes click me!</button>
// </div>
$spacing-sizes: flush 0, XS 1, S 2, D 4, M 6, L 10 !default;
$spacing-base: 3px !default;
@function spacing($n) {
@jnowland
jnowland / freemember-bday-selectors.php
Created July 23, 2013 06:06
Select boxes for birthday in freemember echos out bday_d , bday_m, bday_y for expression engine. Works with PHP on output.
<div class="control-group">
<label for="{pr_form_id}-date-of-birth">Date of Birth</label>
<select id="{embed:form_prefix}-bday_d" name="bday_d" class="dob-day">
<option value="">Day</option>
<?php for ($i=1; $i < 32; $i++) : ?>
<option value="<?php echo $i ?>"
<?php echo ($i == "{bday_d}") ? 'selected="selected"' : "" ?>
>
<?php echo $i ?></option>
@jnowland
jnowland / bem-scss-mod.scss
Last active December 17, 2015 15:39
Just a though of a BEM Nesting idea. Would some SASS like compiler be able to do something like this? "__" and "--" are rather unique to it. I hate writing the same thing out over and over again.
.media{
__img{
--rev{
}
}
__body{
//Simple comment up here to explain that accordion is a accordion with 3 parts blah blah blah
.accordion {
.js & {
display: none;
}
.js .open + & {
display: block;
}
//dont use & unless it changes the order here.
li {
<?php /* making sure we 'orderby' correctly */
query_posts( $query_string . '&orderby=date&order=DEC' ); ?>
<?php if ( have_posts() ) : ?>
<?php
/* Setup */
$display_year = '';
$format = 'd/m/Y';
$year_position = 2;
@jnowland
jnowland / clearfix.sublime-snippet
Created March 14, 2013 05:59
Cleafix snippet
<snippet>
<content><![CDATA[@extend .clearfix;]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>cf</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@jnowland
jnowland / lorempic.sublime-snippet
Created March 14, 2013 05:14
A snippet for getting filler pictures by lorempic + tab
<snippet>
<content><![CDATA[
<img src="http://lorempixel.com/${1:}/${2:}/${3:abstract / animals / business / cats / city / food / nightlife / fashion / people / nature / sports / technics / transport}/${4:Enter a Number 1 / 10}/" width="${1:}" height="${2:}" />
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>lorempic</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->