Skip to content

Instantly share code, notes, and snippets.

View becw's full-sized avatar

Bec White becw

View GitHub Profile
@becw
becw / example.install.php
Last active March 26, 2019 06:53
Enable/revert a feature in a Drupal update hook #drupal7
/**
* EXAMPLE FEATURE UPDATE
* Enable and revert the my_new_feature_name feature.
*/
function example_update_7001() {
// An array of new or changed features; the array keys are feature names,
// values are an array of exportable types as seen in a feature's .info file:
// features[field][] = node-page-body
$features = array(
'my_new_feature_name' => array('field', 'variable'),
@rjpeter2
rjpeter2 / gist:3307956
Created August 9, 2012 20:54
Field Formatter for replacing empty field with another.
<?php
/**
* Implements hook_field_formatter_info().
*/
function custom_field_formatter_info() {
$formatters = array();
$formatters['custom_event_time'] = array(
'label' => t('CUSTOM: Event Time'),
'description' => t('Displays this field normally if it has a value, if empty, it displays the time from field_event_date.'),
'field types' => array('text'),
@davereid
davereid / gist:3012194
Created June 28, 2012 16:05
Workaround for embedding non-image media in WYSIWYG
<?php
/**
* Implements hook_media_token_to_markup_alter().
*
* Allow non-image files to be embedded in the WYSIWYG by converting the
* 'preview' markup to be shown in the WYSIWYG to an image preview of the file.
*/
function custom_media_token_to_markup_alter(&$element, $tag_info, $settings) {
if (!empty($settings['wysiwyg']) && $tag_info['file']->type != 'image') {