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 |
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 | |
$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 | |
/** | |
* 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
# 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 | |
/** | |
* @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
// This solves the problem with last and previous digit addition. | |
function Xbonacci(signature, n){ | |
var totalCallsToMake = n - signature.length; | |
var tempArr = signature.slice(0); | |
const reducer = (accumulator, currentValue) => accumulator + currentValue; | |
// Looping through. | |
for (var i=1; i<=totalCallsToMake; i++) { | |
var lastTwoEl = tempArr.slice(-2); | |
tempArr.push(lastTwoEl.reduce(reducer)); | |
} |
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
var gimme = function (inputArray) { | |
// Clone the input array. | |
var clonedArray = inputArray.slice(0); | |
// Sort it in ascending order. | |
clonedArray.sort(function(a, b){ | |
return a-b | |
}); | |
return inputArray.indexOf(clonedArray[1]); | |
}; |
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 disemvowel(str) { | |
return str.replace(/[aeiou]/gi, ''); | |
} |
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
// Your task is to write a function maskify, which changes all but the last four characters into '#'. | |
// Examples | |
// maskify("4556364607935616") == "############5616" | |
// maskify( "64607935616") == "#######5616" | |
// maskify( "1") == "1" | |
// maskify( "") == "" | |
// "What was the name of your first pet?" | |
// maskify("Skippy") == "##ippy" |
OlderNewer