Skip to content

Instantly share code, notes, and snippets.

View bangpound's full-sized avatar

Benjamin Doherty bangpound

View GitHub Profile
@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;
/**
* 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 / 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));
/**
* 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 / 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;
@mixin content-section {
#content {
.section {
border: {
color: $regrettable_maroon;
style: solid;
width: 1px; }; }
.region-highlight {
.block {
margin: {
@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
@bangpound
bangpound / _bidi-grid.scss
Created January 21, 2011 00:56
Bidirectional Susy grid mixins.
// use with https://github.com/bangpound/compass-susy-plugin/blob/feature%2Frtl/sass/susy/_grid.scss
// html element must have a dir attribute to indicate reading direction.
// e.g. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ar" lang="ar" dir="rtl">
@mixin bidi-columns($n, $context: false) {
[dir="ltr"] & {
@include columns($n, $context, left);
}
[dir="rtl"] & {
@bangpound
bangpound / gist:817801
Created February 9, 2011 03:00
add manage field and display contextual links to nodes.
<?php
/**
* Implement hook_menu_alter().
*/
function bangpound_menu_alter(&$items) {
if (module_exists('field_ui')) {
$items['admin/structure/types/manage/%node_type/fields']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
$items['admin/structure/types/manage/%node_type/display']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
}
<?php
abstract class MigrateFieldHandler extends MigrateHandler {
// abstract function arguments(...)
abstract public function prepare(stdClass $entity, array $field_info, array $instance, array $values);
/**
* Determine the language of the field
*
* @param $entity