Skip to content

Instantly share code, notes, and snippets.

@vdchristelle
vdchristelle / block-subpages.tpl.php
Created October 25, 2013 09:42
custom menu block of siblings with icon
<?php
$max = count(element_children($nodes));
// Set up striping values.
$count = 0;
?>
<div class="overview realisaties homepage">
<ul>
<?php foreach ($nodes as $node) {
$count++;
$attributes = array();
@vdchristelle
vdchristelle / get_default_image.module.php
Created October 8, 2013 07:40
Default image not available in tpl files
/**
* DECLARING THE BLOCK
* Implements hook_block_info().
*/
function the_aim_team_block_info() {
$blocks['teamblock'] = array(
// The name that will appear in the block list.
'info' => t('the AIM team members'),
// Default setting.
'cache' => DRUPAL_CACHE_PER_ROLE,
@vdchristelle
vdchristelle / script.js
Created September 26, 2013 10:24
Function prevents window.resize in jquery firing multiple times
(function ($) {
$(window).smartresize(function() {
// your cool stuff...
});
})(jQuery);
@vdchristelle
vdchristelle / custom.txt
Created September 24, 2013 10:45
Adds an icon to a taxonomy menu block item link - hook taxonomy menu block - rewrite output TMB - TMB term teasers
/**
* Implements hook_taxonomy_menu_block_tree_alter
*/
function custom_taxonomy_menu_block_tree_alter(&$tree, $config) {
switch($config) {
// add icon image to cache of TMB
case '2':
foreach($tree as $tid => $term) {
@vdchristelle
vdchristelle / template.php
Created September 23, 2013 14:51
Function adds the main-menu items to taxonomy menu block
<?php
function the_aim_theme_preprocess_taxonomy_menu_block(&$variables){
//only for block with delta == 1
if ( 1 == $variables['config']['delta']) {
$links = menu_tree('main-menu');
$main_links = array();
foreach ($links as $link) {
@vdchristelle
vdchristelle / background-check.min.js
Created September 23, 2013 14:08
If an element overlaps any of the images, either .background--dark or .background--light is added to it. BackgroundCheck does not change an element's style — you must do so using CSS. Bron: http://www.kennethcachia.com/background-check/
/* BackgroundCheck
http://kennethcachia.com/background-check
v1.0.0 */
!function(a,b){"function"==typeof define&&define.amd?define(b):a.BackgroundCheck=b(a)}(this,function(){"use strict";function a(a){if(void 0===a||void 0===a.targets)throw"Missing attributes";w.targets=d(a.targets),w.images=d(a.images||"img"),w.changeParent=a.changeParent||!1,w.threshold=a.threshold||50,w.minOverlap=a.minOverlap||50,w.classes=a.classes||{dark:"background--dark",light:"background--light"},w.windowEvents=a.windowEvents||!0,w.maxDuration=a.maxDuration||500,w.mask=a.mask||{r:0,g:255,b:0},w.debug=a.debug||!1,void 0===q&&(e(),q&&(r.style.position="fixed",r.style.top="0px",r.style.left="0px",r.style.width="100%",r.style.height="100%",window.addEventListener(v,n.bind(null,function(){g(),m()})),window.addEventListener("scroll",n.bind(null,m)),g(),m()))}function b(){q=null,r=null,s=null,w={},t&&clearTimeout(t)}function c(a){p("debug")&&console.log(a)}function d(a){var b=a;if("string"==typeof a?b=document.querySelectorAll(a):1==
@vdchristelle
vdchristelle / template.php
Created September 23, 2013 12:10
Override the value of the h1_title with the commercial title on taxonomy pages (for old sites)
<?php
//change node title to commercial title on taxonomy pages
if (isset($variables['page']['content']['system_main']['term_heading']['term']['#term']->tid)) {
$term_info = taxonomy_term_load($variables['page']['content']['system_main']['term_heading']['term']['#term']->tid);
if (isset($term_info) && !empty($term_info)){
$variables['h1_title'] = $term_info->the_aim_seo_pagetitle['und'][0]['value'];
}
}
//optie 2
@vdchristelle
vdchristelle / animated logo on scroll.js
Created September 18, 2013 12:42
Logo gaat naar een position fixed als je naar beneden scrollt source: http://www.smartwebconf.com/
(function($) {
// grab the initial top offset of the navigation
var sticky_navigation_offset_top = $('.content').offset().top;
// our function that decides weather the navigation bar should have "fixed" css position or not.
var sticky_navigation = function(){
var scroll_top = $(window).scrollTop(); // our current vertical position from the top
// if we've scrolled more than the navigation, change its position to fixed to stick to top, otherwise change it back to relative
if (scroll_top > sticky_navigation_offset_top) {
$('.nav-right').css('margin-left','100px');
@vdchristelle
vdchristelle / add class nextitem to list item.js
Created September 9, 2013 09:26
Add extra css class to the lext li for styling the border
//add extra css class to the lext li for styling the border
$('.main-menu').find('li.active').next().addClass('nextitem');
@vdchristelle
vdchristelle / responsive theming helper.css
Created September 9, 2013 08:01
Responsive theming helper
/**
* responsive theming helper
*/
/* body {
&:before {
position: fixed; top: 60px; right: 0; z-index: 1; width: 100px; height: 30px; padding: 5px 10px; font-weight: bold; font-size: 16px; line-height: 30px; content:"default"; background-color:blue; color: white; text-align: right;
@include at-breakpoint($break-1){content:"break-1";background-color:green;color:black;}
@include at-breakpoint($break-2){content:"break-2";background-color:red;}