Skip to content

Instantly share code, notes, and snippets.

@barraponto
Created March 20, 2012 05:05
Show Gist options
  • Select an option

  • Save barraponto/2131544 to your computer and use it in GitHub Desktop.

Select an option

Save barraponto/2131544 to your computer and use it in GitHub Desktop.
D6: How to modify the #theme and #formatter of a field based on build_mode
/**
* Implements hook_nodeapi().
*/
function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'view') {
if ($node->type == 'business' && $node->build_mode == 'mobile') {
// change the field_photos formatter
foreach ($node->content['field_photos']['field']['items'] as $key => $item) {
$node->content['field_photos']['field']['items'][$key]['#formatter'] = 'my_preset_imagelink';
$node->content['field_photos']['field']['items'][$key]['#theme'] = 'imagecache_formatter_my_preset_imagelink';
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment