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 | |
/** | |
* @file | |
* A tabledrag example - without theming the whole form. | |
*/ | |
/** | |
* Implements hook_menu(). | |
*/ |
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
# Find last commit for the deleted file | |
git rev-list -n 1 HEAD -- $path | |
# Checkout the commit before the the delete happened | |
git checkout $commit^ -- $path |
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_element_info_alter(). | |
* | |
* Sets the text format processor to a custom callback function. | |
* This code is taken from the Better Formats module. | |
*/ | |
function module_element_info_alter(&$type) { | |
if (isset($type['text_format']['#process'])) { | |
foreach ($type['text_format']['#process'] as &$callback) { |
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 | |
$field_collection_item = field_collection_item_load($id); | |
$item_wrapper = entity_metadata_wrapper('field_collection_item', $field_collection_item); | |
// this results in an error if the field_contrib_headshot field is empty | |
$headshot = $item_wrapper->field_contributor->field_contrib_headshot->value(); | |
Solution: | |
// EntityStructureWrapper implements the __isset() function according the principe of Overloading. | |
$headshot = 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 | |
$panelizer_nodes = db_select('node', 'n'); | |
$panelizer_nodes->leftjoin('panelizer_entity', 'e', 'e.entity_id = n.nid'); | |
$panelizer_nodes->fields('e', array('entity_id')); | |
$panelizer_nodes->condition('entity_type', 'node'); | |
$panelizer_nodes->condition('did', 0, '<>'); | |
$panelizer_nodes->condition('n.status ', 1, '='); | |
$panelizer_nodes->condition('n.type', 'content_type'); | |
$result = $panelizer_nodes->groupBy('e.entity_id')->execute()->fetchCol('entity_id'); |
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 | |
$body_text_alter_params = array( | |
'max_length' => 300, | |
'ellipsis' => FALSE, | |
'word_boundary' => TRUE, | |
'html' => FALSE, | |
); | |
// Removes unnecessary markup. | |
$trimmed_body = check_plain(strip_tags($value->body_value, '<p>')); | |
// Trimming the body text as per the parameters defined in |
NewerOlder