Skip to content

Instantly share code, notes, and snippets.

{# Get the IDs of all the sections #}
{% set currentSectionId = entry.id %}
{% set allSectionIds = craft.entries.section('myStructure').level(1).ids() %}
{# Define var before loop #}
{% set sectionNumber = '' %}
{# Loop through all section IDs and find the one that matches the current #}
{% for key, sectionId in allSectionIds if sectionId == currentSectionId %}
@markgoodyear
markgoodyear / SassMeister-input-HTML.html
Created November 27, 2014 10:41
Generated by SassMeister.com.
<p>Normal</p>
<a class="btn btn--primary">Button</a>
<a class="btn btn--primary btn--outline">Button</a>
<a class="btn btn--secondary">Button</a>
<a class="btn btn--secondary btn--outline">Button</a>
<a class="btn btn--tertiary">Button</a>
<a class="btn btn--tertiary btn--outline">Button</a>
@markgoodyear
markgoodyear / SassMeister-input-HTML.html
Created November 26, 2014 22:56
Generated by SassMeister.com.
<p>Normal</p>
<a class="btn btn--primary">Button</a>
<a class="btn btn--primary btn--outline">Button</a>
<a class="btn btn--secondary">Button</a>
<a class="btn btn--secondary btn--outline">Button</a>
<a class="btn btn--tertiary">Button</a>
<a class="btn btn--tertiary btn--outline">Button</a>
function extend (target, source) {
var a = Object.create(target);
Object.keys(source).map(function (prop) {
a[prop] = source[prop];
});
return a;
};
gulp.task('static', function() {
return gulp.src('src/static/**')
.pipe(gulp.dest('build'));
}
@markgoodyear
markgoodyear / functions.php
Last active August 29, 2015 14:02
WordPress Dirty Active Menu
<?php
add_filter( 'nav_menu_css_class', 'add_parent_url_menu_class', 10, 2 );
function add_parent_url_menu_class( $classes = array(), $item = false ) {
// Get current URL
$current_url = current_url();
// Get homepage URL
@markgoodyear
markgoodyear / functions.php
Created April 18, 2014 11:59
Enqueue WordPress
<?php
// All scripts to load here
function load_scripts() {
// Register script
wp_register_script('scrollup', get_template_directory_uri() . '/path/to/scripts/jquery.scrollUp.min.js', array('jquery'), '2.3.3', true );
// Enqueue it
wp_enqueue_script('scrollup');
@markgoodyear
markgoodyear / gist:9100177
Last active August 29, 2015 13:56
Example of a dev flag for gulp
// Define your plugins here, make sure you have `gulp-util`...
var gutil = require('gulp-util');
/**
* Define dev CLI flag
* Run `gulp --dev`
*/
var isDev = gutil.env.dev;
gulp.task('scripts', function() {