Skip to content

Instantly share code, notes, and snippets.

View robdecker's full-sized avatar

Rob Decker robdecker

View GitHub Profile
@robdecker
robdecker / template.php
Last active November 2, 2019 02:11
[Put the path to the theme in Drupal.settings for use in javascript files] #d7
<?php
function mytheme_preprocess_page(&$vars) {
// Add the path to this theme to Drupal.settings
$setting['pathToTheme'] = path_to_theme();
drupal_add_js($setting, 'setting');
}
// OR:
@robdecker
robdecker / template.php
Last active November 2, 2019 04:00
[Add active contexts to body classes] Insert into THEME_preprocess_page() #d6
// List active contexts from "context" module.
$contexts = context_active_contexts();
foreach ($contexts as $context) {
$vars['body_classes'] .= ' context_' . $context->name;
}
@robdecker
robdecker / clear-drupal-cache.php
Last active November 2, 2019 02:12 — forked from samsargent/clear-drupal-cache.php
[Clear all caches from a php file] #d6
<?php
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
?>
@robdecker
robdecker / style.css
Last active November 2, 2019 02:13
[Clearfix. IE6+] #css
.group:before,
.group:after {
content: "";
display: table;
}
.group:after {
clear: both;
}
.group {
zoom: 1; /* For IE 6/7 (trigger hasLayout) */
@robdecker
robdecker / style.css
Last active November 2, 2019 02:13
[Clearfix. IE8+] #css
.group:after {
content: "";
display: table;
clear: both;
}
@robdecker
robdecker / node.tpl.php
Last active November 2, 2019 02:14
[Theme ImageCache image] #d6
$image = theme('imagecache', 'imagecache-preset', $node->field_main_image[0]['filepath']);
@robdecker
robdecker / node.tpl.php
Last active November 2, 2019 02:15
[Theme an image (basic info only)] #d7
print theme('image_style', array( 'path' => $field[0]['uri'], 'style_name' => 'gallery_thumbnail'));
@robdecker
robdecker / node.tpl.php
Last active November 2, 2019 02:14
[Theme an image (with html attributes)] #d7
print theme('image_style', array( 'path' => $images[$i]['uri'], 'style_name' => 'photo-slideshow', 'attributes' => array('class' => 'img'.$i)));
@robdecker
robdecker / template.php
Last active November 2, 2019 02:15
[Snippet for theme_breadcrumb] #d7
/**
* Implements theme_breadcrumb().
*/
function THEME_breadcrumb(&$vars) {
$breadcrumb = $vars['breadcrumb'];
if (!empty($breadcrumb)) {
$output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
$breadcrumb_separator = '<span class="separator"> &raquo; </span>';
$output .= '<div class="breadcrumb">' . implode($breadcrumb_separator, $breadcrumb) . '</div>';
return $output;
@robdecker
robdecker / module.info
Last active November 2, 2019 02:16
[Module.info stub] #d7
name =
description = ""
package = Other
core = 7.x
configure = admin/config/path/to/config
dependencies[] =
files[] =