This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// See http://dominiquedecooman.com/blog/drupal-7-tip-add-contextual-links-anything | |
// See http://drupal.org/node/1089922 | |
// hook_menu | |
// Menu item must have 'context' set to MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE | |
function mymodule_menu() { | |
return array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_field_extra_fields(). | |
*/ | |
function mymodule_field_extra_fields() { | |
// $extra['entity_type']['bundle'] | |
$extra['node']['my_content_type'] = array( | |
'display' => array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var id in Drupal.settings.datePopup) { | |
$('#'+id).bind('keyup', function(e){ | |
var code = (e.keyCode ? e.keyCode : e.which); | |
if (code==46 || code==8) { | |
$(this).val(""); | |
} | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("[type='radio']").change(function(){ | |
$(this) | |
.filter(':checked') | |
.parent().addClass('checked') | |
.siblings().removeClass('checked') | |
}); | |
$("[type='checkbox']").change(function(){ | |
if ($(this).checked) { | |
$(this).parent().addClass('checked') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mymodule_admin_image() { | |
$form = array(); | |
// Image wrapper | |
$form['image_default'] = array( | |
'#type'=>'fieldset', | |
'#title' => "Image par defaut", | |
'#collapsible' => TRUE, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Add class and attributes from custom blocks | |
*/ | |
function phptemplate_preprocess_block(&$vars) { | |
if(isset($vars['block']->attributes)) { | |
if(isset($vars['block']->attributes['class'])) { | |
$vars['classes_array'] = array_merge($vars['classes_array'], $vars['block']->attributes['class']); | |
unset($vars['block']->attributes['class']); | |
} | |
if(!empty($vars['block']->attributes)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_drush_command(). | |
*/ | |
function custom_local_drush_command() { | |
$items['files-fix-permissions'] = array( | |
'description' => 'Fix file permissions', | |
'aliases' => array('ffp'), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_form_FORM_ID_alter(). | |
* | |
* Adds menu 'class' attribute options to the edit menu item form. | |
*/ | |
function mymodule_form_menu_edit_item_alter(&$form, $form_state) { | |
// Get item | |
$item = $form['original_item']['#value']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Touch events | |
*/ | |
// wrapper is a DOM element | |
wrapper.touch = {} | |
wrapper.get(0).ontouchstart = function(e) { | |
// Store start position | |
wrapper.touch.x = e.touches[0].clientX; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _node_view_static_field($field_name, $title, $markup, $weight = 0) { | |
return array( | |
'#theme' => "field", | |
'#weight' => $weight, | |
'#title' => $title, | |
'#access' => TRUE, | |
'#label_display' => "inline", | |
'#view_mode' => "full", | |
'#language' => "und", | |
'#field_name' => $field_name, |