Skip to content

Instantly share code, notes, and snippets.

View pixelwhip's full-sized avatar

John Ferris pixelwhip

View GitHub Profile
/**
* Implements hook_block_view_alter().
*/
function ex_user_block_view_masquerade_masquerade_alter(&$data, $block) {
// Allow the block to be hidden using a conf variable.
if (!variable_get('ex_user_show_masquerade_block', 1)) {
$data = array();
return;
}
/**
* Implements hook_block_view_MODULE_DELTA_alter().
*/
function ex_user_block_view_masquerade_masquerade_alter(&$data, $block) {
// Allow the block to be hidden using a conf variable.
if (!variable_get('ex_user_show_masquerade_block', 1)) {
$data = array();
return;
}
@pixelwhip
pixelwhip / element.inc
Created February 25, 2012 23:44
Creates an element object as a basis for a more consistent render array.
<?php
/**
* @file
* Creates an element object as a basis for a more consistent render array.
*
* The current Drupal 7 render array is very powerful but hard to manage due to
* inconsistencies and information overload. This proof of concept aims to
* create a better separation between what is meant to be rendered and what is
* extra contextual information used by module developers. It tries to strike
* a balance between flexibility and discoverability. The general idea is
@pixelwhip
pixelwhip / android-background.patch
Created March 1, 2012 15:06
Fixes the background image issue on the Galaxy Nexus
=== modified file 'sites/all/themes/denver2012/sass/screen.scss'
--- sites/all/themes/denver2012/sass/screen.scss 2012-02-22 07:13:16 +0000
+++ sites/all/themes/denver2012/sass/screen.scss 2012-02-29 18:55:13 +0000
@@ -965,7 +973,7 @@
#wrapper {
position: relative;
- z-index: 0;
+ z-index: 1;
}
@pixelwhip
pixelwhip / styleguide.html
Created March 7, 2012 23:52
A style guide to use as a basis for styling basic html tags.
<!-- Quick & Dirty Style Guide -->
<!-- Paste this into the body of a node to give you something to style. -->
<!-- by John Ferris @pixel_whip http://pixel-whip.com -->
<p class="intro">Intro Paragraph Style: It’s helpful to give your readers a quick introduction to the page. That’s what this paragraph will do for them.</p>
<h2>Section Heading (h2)</h2>
<img src="http://placekitten.com/600/288" />
<p><img src="http://placekitten.com/340/240" class="image-left"/>Basic Paragraph Style: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, this is a link quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit amet, this is a visited link consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
<p><img src="http://placekitten.com/216/216" class="image-right"/>Ut enim ad minim veniam, quis nostrud exercitation this is a link
@pixelwhip
pixelwhip / _variables.scss
Created April 18, 2012 05:34
Sample scss files for establishing a baseline for a new site. I've been starting every project with a variation of these files. They get refined each time and have proved super useful.
//
// @file
// Sitewide imports, variables and mixins.
//
@import "compass/css3";
@import "compass/typography";
@import "sassy-buttons";
@import "utilities";
@import "grids";
@pixelwhip
pixelwhip / template.php
Created April 18, 2012 05:43
This is simple alter function I had to write while addressing an issue on the DrupalCon site. It led to this blog post. http://pixel-whip.com/blog/12/03/all-cool-kids-back-bus
<?php
/**
* Implements hook_js_alter()
*/
function shizzle_js_alter(&$javascript) {
// Collect the scripts we want in to remain in the header scope.
$header_scripts = array(
'sites/all/libraries/modernizr/modernizr.min.js',
);
@pixelwhip
pixelwhip / screen.scss
Created April 18, 2012 05:56
How I make blocks sexy with abstracted classes.
//
// Generic block styles
//
.block {
@include margin-trailer(1);
}
.block-rounded {
@media screen and (min-width: 420px) {
@pixelwhip
pixelwhip / block.tpl.php
Created May 23, 2012 16:05
Drupal: Adding classes to blocks
<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
<h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php endif;?>
<?php print render($title_suffix); ?>
<div <?php print $content_attributes; ?>>
<?php print $content ?>
@pixelwhip
pixelwhip / template.php
Created May 30, 2012 13:26
Adding icons to menu links in Drupal
<?php
/**
* Custom implementation of theme_menu_link() for including icons.
*/
function cic_menu_link__icon(array $variables) {
$element = $variables['element'];
$sub_menu = '';
/* Prevent the <span> tag from being escaped */