Skip to content

Instantly share code, notes, and snippets.

View bangpound's full-sized avatar

Benjamin Doherty bangpound

View GitHub Profile
@bangpound
bangpound / teaser_preprocess.php
Created January 1, 2011 21:09
Preprocess function to add filtered node body and teaser to template variables.
<?php
/**
* Implement hook_preprocess_node().
*/
function example_preprocess_node(&$vars) {
// The node is reloaded from the static cache to generate new template
// variables that contain just the filtered body and teaser. node_view()
// unsets the node object's teaser or body property depending on the build
@mixin content-section {
#content {
.section {
border: {
color: $regrettable_maroon;
style: solid;
width: 1px; }; }
.region-highlight {
.block {
margin: {
@bangpound
bangpound / boxes_ctools_content.inc.php
Created October 21, 2010 02:39
Boxes plugin for ctools content types.
<?php
// $Id$
/**
* Base class for all ctools content types.
*/
abstract class boxes_ctools_content extends boxes_box {
public $content_type;
public $content_type_plugin;
/**
* Migrate {taxonomy_term_node} table to field storage.
*/
function taxonomy_update_7005(&$sandbox) {
// This is a multi-pass update. On the first call we need to initialize some
// variables.
if (!isset($sandbox['total'])) {
$sandbox['last'] = 0;
$sandbox['count'] = 0;
@bangpound
bangpound / microformat.php
Created July 23, 2010 20:56
alter Drupal 6 theme output after rendering with QueryPath
/**
* Microformat function.
*/
function microformat() {
$args = func_get_args();
$hooks = array_shift($args);
if (!is_array($hooks)) {
$hooks = array($hooks);
}
$output = call_user_func_array('theme', array_merge(array($hooks), $args));
/**
* reset all the radio buttons with a given name
*
* @param string fieldName
* @param object form
* @return null
*/
function unselectRadio(fieldName, form)
{
for( i=0; i < document.forms[form].elements.length; i++) {
@bangpound
bangpound / _layout.scss
Created June 25, 2010 02:20
Layout mixins for Drupal's Zen 2 theme
@import "blueprint";
$zen-first-sidebar-width: 200px !default;
$zen-second-sidebar-width: 200px !default;
$zen-content-width: 560px !default;
$zen-gutter: 10px !default;
$zen-navigation-height: 1.5em !default;
$zen-page-width: $zen-first-sidebar-width + $zen-content-width + $zen-second-sidebar-width !default;
/*global jQuery */
"use strict";
/**
* jQuery balance plugin.
*
* Adds 1px padding to the right side of an element. If text wraps and
* causes the height of the element to increase, remove 1 pixel.
*
@import __base.sass
@import compass
$zen_first_sidebar_width: $zen_blueprint_left_units * $blueprint_grid_outer_width
$zen_second_sidebar_width: $zen_blueprint_right_units * $blueprint_grid_outer_width
$zen_content_width: $zen_blueprint_content_units * $blueprint_grid_outer_width - $blueprint_grid_margin
$zen_gutter: $blueprint_grid_margin
$zen_navbar_height: 40px
$zen_page_width: $zen_first_sidebar_width + $zen_content_width + $zen_second_sidebar_width
@bangpound
bangpound / compass-rgbapng.rb
Created April 24, 2010 20:08
Cross-browser translucent backgrounds. Creates RGBa PNG files at compile time.
# bangpound does not know Ruby.
#
# inspired by http://www.alloycode.com/2009/6/19/fun-with-rmagick
#
# RGBa PNG method described at http://leaverou.me/2009/02/bulletproof-cross-browser-rgba-backgrounds/
module Sass::Script::Functions
def rgbapng(color)
require 'rubygems'
require "RMagick"