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
@markhalliwell
markhalliwell / 1-issue.comments.alter.js
Last active August 29, 2015 13:56
Issue comments alter
/**
* THIS FILE ALTERS ANY ISSUE WITH THE NEW STYLING. IT AUTOMATICALLY INCLUDES THE CSS FILE
* BELOW. JUST COPY AND PASTE THIS IN YOUR INSPECTOR CONSOLE.
**/
(function ($) {
var localStorageSupported = false;
var enableTimeago = false;
// Only enable timago if user's browser has localStorage support (so they can
// double click to enable and disable at will).
if (typeof window.localStorage !== 'undefined') {
{% 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'
<?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 / 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 <mark.carver@me.com>"
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
respawn
respawn limit 2 5
@markhalliwell
markhalliwell / page.tpl.php
Created November 23, 2011 16:54
Replaceable Image Theme Settings
<?php
/**************
* IMPORTANT:
* Place these styles in your page.tpl.php file to override the style.css.
* You will need to make sure they match your themes selectors.
**************/
?>
<style type="text/css" media="all">
#page{
background-attachment:<?php print $background_image_attachment; ?>;
@markhalliwell
markhalliwell / 1-template.php
Created November 5, 2012 16:59
Drupal 7 - Converting a Views Unformatted List Into Columns
<?php
/**
* Implements hook_preprocess_views_view_unformatted().
*/
function YOUR_THEME_preprocess_views_view_unformatted(&$variables) {
// Determine if this view's content should render in columns.
// @see: _YOUR_THEME_views_columns();
_YOUR_THEME_views_columns($variables, array(
'articles|page' => 2,
@markhalliwell
markhalliwell / d8-reset.sh
Created July 21, 2013 16:47
Deletes settings.php, removes the php config dir, drops and creates the database table.
#!/bin/bash
sudo rm -rf /sandbox/sites/d8.sandbox/sites/default/settings.php;
sudo rm -rf /sandbox/sites/d8.sandbox/sites/default/files/php/;
mysql -u root -proot -e 'DROP DATABASE `d8.sandbox`; CREATE DATABASE `d8.sandbox`;'
@markhalliwell
markhalliwell / perm.sh
Created July 21, 2013 16:53
Change the ownership settings according to how your www environment is setup.
#!/bin/bash
echo 'Setting ownership to _www:staff ...';
sudo chown -R _www:staff ./;
echo 'Setting directory permissions to 0755 ...';
sudo find . -type d -exec chmod u=rwx,g=rwx,o=rx '{}' \;
echo 'Setting file permissions to 0644 ...';
sudo find . -type f -exec chmod u=rw,g=rw,o=r '{}' \;
<?php
function MODULE_form_alter(&$form, $form_state, $form_id) {
if (!empty($form['#node'] && !empty($form['#node_edit_form'])) {
$node = $form['#node'];
$action = in_array('add', args()) ? t('Create new') : t('Edit existing');
switch ($node->type) {
case 'article': drupal_set_title(t('!action basic article', array('!action' => $action))); break;
case 'blog': drupal_set_title(t('!action blog article', array('!action' => $action))); break;
case 'audio': drupal_set_title(t('!action audio conent', array('!action' => $action))); break;