Skip to content

Instantly share code, notes, and snippets.

View markhalliwell's full-sized avatar
🦄
unicorns!

Mark Halliwell markhalliwell

🦄
unicorns!
  • Fort Worth, Texas, USA
View GitHub Profile
{% attributes.class.add([
'node',
'node--type-' ~ node.bundle|class,
node.promoted ? 'node--promoted',
node.sticky ? 'node--sticky',
not node.published ? 'node--unpublished',
preview ? 'node--preview',
'node--view-mode-' ~ view_mode|class
]).remove([
'some-module-class'
@markhalliwell
markhalliwell / stark2.theme.php
Created July 8, 2014 15:45
Adding external/inline resources via #attached in a Drupal 8 theme
<?php
/**
* @file
* Example of how to attach external and inline resources for a theme via the
* #attached render array method in 8.x.
*/
/**
* Helper function for attaching resources to a render array.
*/
<?php
$items = array();
$build['list'] = array(
'#theme' => 'item_list',
'#items' => $items,
'#empty' => t('You have no content, please <a href="!link">create some</a>.', array(
'!link' => 'node/add',
),
@markhalliwell
markhalliwell / menu-tree.vars.php
Last active August 29, 2015 14:04
Menu tree context alter
<?php
/**
* Implements hook_theme_registry_alter().
*/
function THEMENAME_theme_registry_alter(&$theme_registry) {
array_unshift($theme_registry['menu_tree']['preprocess functions'], 'THEMENAME_menu_tree_alter');
}
/**
* Helper function for adding the tree context to the variables.
@markhalliwell
markhalliwell / cd-tests.sh
Created August 18, 2014 14:14
cocoaDialog Tests
#!/bin/bash
# Script: cocoaDialogTests.sh
# Author: Mark Carver
# Created: 2011-09-23
# Updated: 2012-07-24
# Copyright (c) 2012 Mark Carver. All rights reserved.
cocoaDialog(){
# Replace this with your path if it isn't installed in the applications folder.
/Users/Shared/Applications/cocoaDialog.app/Contents/MacOS/cocoaDialog "${@}";
@markhalliwell
markhalliwell / rsync-progress.sh
Last active January 22, 2016 13:25
This only really works if rsyncing entire folders. Single files do work, however it will just appear to stand still (no progress). Also, change the path to cocoaDialog accordingly.
#!/bin/bash
# cocoaDialog Rsync Progress
#
# Rsync files using the cocoaDialog progress bar. Example usage:
# $ rsync -avr --progress ~/source ~/destination | ./rsync-progress.sh
#
# Copyright (C) 2014 Mark Carver
#
# Adapted from Kevin Hendricks example code
@markhalliwell
markhalliwell / sass-helper-classes.scss
Created January 27, 2015 18:52
SASS Helper Classes
// Helper classes.
@each $property in (border, margin, padding) {
@each $direction in ('', -left, -right, -top, -bottom) {
.#{$property}#{$direction} {
@if $property == border {
#{$property}#{$direction}: 1px solid $gray-lighter;
}
@else {
#{$property}#{$direction}: 1em;
}
@markhalliwell
markhalliwell / bot.conf
Created March 20, 2015 22:00
Create this file as /etc/init/bot.conf
# Drush Bot Service
description "Drush Bot"
author "Mark Carver <[email protected]>"
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
respawn
respawn limit 2 5
@markhalliwell
markhalliwell / ViewsExposedForm.php
Created July 11, 2016 18:22
Drupal Bootstrap 8.x-3.x - Views Exposed Form Toggle
<?php
// In your sub-theme, create this file ./THEMENAME/src/Plugin/Preprocess/ViewsExposedForm.php and place this contents in it.
/**
* @file
* Contains \Drupal\THEMENAME\Plugin\Preprocess\ViewsExposedForm.
*/
namespace Drupal\THEMENAME\Plugin\Preprocess;
@markhalliwell
markhalliwell / SearchBlockForm.php
Last active October 29, 2016 00:51 — forked from lanoxx/bootstrap_subtheme.theme
Support placing the navbar into the top navigation
<?php
namespace Drupal\bootstrap_mobildata\Plugin\Form;
use Drupal\bootstrap\Annotation\BootstrapForm;
use Drupal\bootstrap\Utility\Element;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_FORM_ID_alter().
*