Skip to content

Instantly share code, notes, and snippets.

View driesdelaey's full-sized avatar

Dries Delaey driesdelaey

  • Koksijde
View GitHub Profile
@driesdelaey
driesdelaey / template.php
Created May 10, 2012 11:59
Printing field+label in preprocess_node
<?php
function mytheme_preprocess_node(&$vars,$hook) {
// PRODUCTTABS
if($vars['type'] == 'products' && $vars['view_mode'] == 'full') {
// CHECK IF NODE HAS TECHINFO
if (isset($vars['field_technische_informatie'][0])) {
@driesdelaey
driesdelaey / field--field-image.tpl.php
Created September 6, 2012 20:13
Theming a (multi-) image field
<?php if ($element['#view_mode'] == "full") { // styling image in full display mode?>
<div class="flexslider"<?php print $attributes; ?>>
<ul class="slides"<?php print $content_attributes; ?>>
<?php foreach ($items as $delta => $item): ?>
<li<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></li>
<?php endforeach; ?>
</ul>
</div>
@driesdelaey
driesdelaey / activatemenu.module
Created September 7, 2012 12:49
Custom module to set the activetrail in your menu on a certain content type
<?php
/**
* Implements hook_node_view().
*/
function activatemenu_node_view($node, $view_mode, $langcode) {
// Check for nodes of type "Service".
if($node->type == 'news'){
menu_tree_set_path('main-menu', 'node/56');
@driesdelaey
driesdelaey / autoclick.js
Created September 19, 2012 13:25
JS get querystring 'the_link' and onload : trigger click on link with the class 'the_link'
$(document).ready(function() {
/* FUNCTION TO READ QUERYSTRING PARAM */
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (!results) { return 0; }
return results[1] || 0;}
/* GET URLPARAM MONTH */
@driesdelaey
driesdelaey / template.php
Created September 25, 2012 12:43
truncate breadcrumbtitle
/**
* THEMING BREADCRUMBS
*/
function myubertheme_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
if (!empty($breadcrumb)) {
// Provide a navigational heading to give context for breadcrumb links to
// screen-reader users. Make the heading invisible with .element-invisible.
@driesdelaey
driesdelaey / template.php
Created September 26, 2012 14:48
theme a specific menu
function MYTHEME_menu_tree__MY_MENU_NAME(&$variables) {
return '<div class="thespecialwrapperclassiwant"><ul class="menu nav">' . $variables['tree'] . '</ul></div>';
}
@driesdelaey
driesdelaey / template.php
Created September 26, 2012 14:50
update jquery for frontend only
/**
* UPDATE JQUERY FOR FRONTEND ONLY
*/
function MYTHEME_js_alter(&$javascript) {
// Swap out jQuery to use an updated version of the library.
$javascript['misc/jquery.js']['data'] = drupal_get_path('theme', 'MYTHEME').'/js/jquery-1.7.2.min.js';
}
@driesdelaey
driesdelaey / page.tpl.php
Created October 1, 2012 13:18
print language dependant logo from theme folder on frontpage
<?php if ($is_front): ?>
<img src="<?php print base_path() . path_to_theme(); ?>/img/logo-<?php print $activelang; ?>.png" class="logo" />
<?php endif; ?>
@driesdelaey
driesdelaey / header.php
Created October 24, 2012 08:29
print image_field as background image
print '<div class="visual" style="background-image: url(' . file_create_url($header_waarde['#item']['uri']) . ');"></div>';
#crappycode :-)
@driesdelaey
driesdelaey / bookmarklet.html
Created November 6, 2012 09:57
Bookmarklet to go to Drupal's Performance page
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Bookmarklet </title>
</head>
<body>