Skip to content

Instantly share code, notes, and snippets.

/**
* Computed field callback for calculating the highest review date of all
* field collection items on this profile.
*
* @param $entity_field
* @param $entity_type
* @param $entity
* @param $field
* @param $instance
* @param $langcode
@marcusx
marcusx / define_date_formats_in_code.php
Created January 13, 2014 14:04
How to define date formats in a Drupal modules as a features export is only exporting half of the information.
<?php
/**
* Implements hook_date_formats().
*
*/
function my_module_date_formats() {
return array(
array(
'type' => 'my_module_year_only',
'format' => 'Y',
@marcusx
marcusx / add_class_example.php
Created December 11, 2013 10:57
How to add a class around.
function hook_preprocess_entity(&$variables) {
if ($variables['content_element']->type == 'tour_item') {
$content_element_wrapper = entity_metadata_wrapper('content_element', $variables['content_element']);
$value = $content_element_wrapper->field_text_position->value();
// Add some class to the tour item wrapper. Decide dependent on the value above.
$variables['classes_array'][] = 'text-left';
}
}
@marcusx
marcusx / media_wysiwyg_test.build
Last active December 30, 2015 05:49
A drush make file for setting up a drupal media / wysiwyg integration test system.
core = 7.x
api = 2
projects[drupal][version] = "7.24"
; Modules
; =======
projects[views][version] = 3.7
projects[views][type] = "module"
projects[views][subdir] = "contrib"