Skip to content

Instantly share code, notes, and snippets.

@driesd
driesd / get_parameter_by_name.js
Created August 29, 2013 08:46
Gets any querystring parameter by name (with JavaScript)
//GETS ANY QUERYSTRING PARAMETER BY NAME
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
@driesd
driesd / block_cache_disable.php
Created August 29, 2013 10:08
Disable block cache for a specific block
<?php
//DISABLE BLOCK CACHE
function mytheme_block_info_alter(&$blocks, $theme, $code_blocks) {
$blocks['addtoany']['addtoany_button']['cache'] = DRUPAL_NO_CACHE;
}
@driesd
driesd / custom_block_render.php
Created August 29, 2013 10:09
Render a specific block
<?php
//CUSTOM BLOCK RENDERING
function mytheme_block_render($module, $block_id) {
$block = block_load($module, $block_id);
$block_content = _block_render_blocks(array($block));
$build = _block_get_renderable_array($block_content);
$block_rendered = drupal_render($build);
print $block_rendered;
}
@driesd
driesd / process_field.php
Created August 29, 2013 12:16
Processing fields
<?php
//NEEDED TO MAKE FIELD PROCESSING POSSIBLE PER FIELD
function mytheme_process_field(&$variables) {
$function = 'mytheme_process_field__'. $variables['element']['#field_name'];
if(function_exists($function)) {
$variables = $function($variables);
}
}
@driesd
driesd / file_format_file_size.php
Created August 29, 2013 13:16
Formats a file size (Bytes) into something readable (KB, MB, ...)
<?php
function __format_file_fize_size( $size, $display_bytes=false ) {
if( $size < 1024 )
$filesize = $size . ' bytes';
elseif( $size >= 1024 && $size < 1048576 )
$filesize = round( $size/1024, 2 ) . ' KB';
elseif( $size >= 1048576 )
$filesize = round( $size/1048576, 2 ) . ' MB';
@driesd
driesd / custom_tokens.info
Created September 3, 2013 07:36
Provides a custom token in Drupal
name = "Custom tokens"
description = "Custom module to provide custom tokens"
package = "Custom"
core = 7.x
@driesd
driesd / custom_tax_remove_desc.module
Created September 5, 2013 07:27
Taxonomy: Remove the description field
function custom_tax_remove_desc_form_taxonomy_form_term_alter(&$form, &$form_state, $form_id) {
$form['description']['#access'] = FALSE;
}
@driesd
driesd / commerce_euro.info
Created September 17, 2013 06:36
Commerce: Places the EURO symbol in front of the price value
name = "Commerce - EURO symbol fix"
description = "Places the EURO symbol in front of the price value"
core=7.x
package = "Commerce"
files[] = commerce_euro.module
@driesd
driesd / custom_termview_langfix.info
Created September 17, 2013 10:31
Adds the language filter condition to taxonomy term views
name = The AIM - Views term language
description = Fix / Add the language filter to taxonomy term views
core = 7.x
package = "Custom"
dependencies[] = "views"
dependencies[] = "views_ui"
dependencies[] = "i18n_taxonomy"
@driesd
driesd / select_input_text_on_click.js
Created September 19, 2013 12:43
Select the input field text on click
$('body').delegate('input', 'click', function () {
$(this).select();
});