Skip to content

Instantly share code, notes, and snippets.

@sameronline
Created December 5, 2011 23:54
Show Gist options
  • Save sameronline/1435978 to your computer and use it in GitHub Desktop.
Save sameronline/1435978 to your computer and use it in GitHub Desktop.
customformatter example
<?php
function hook_field_formatter_info() {
return array(
'youtube_video' => array(
'label' => t('Youtube Video'),
'field types' => array('text'),
)
);
}
function hook_theme() {
return array(
'MODULENAME_formatter_youtube_video' => array(
'arguments' =>array('element' => NULL),
),
'example_formatter_plain' => array(
'arguments' =>array('element' => NULL),
),
);
}
function theme_MODULENAME_formatter_youtube_video($element){
dsm($element['#item']['value']);
return "";
}
$width= variable_get("youtube_size_width",400);
<iframe width="$width" height="315" src="http://www.youtube.com/embed/zUo1ICUAR1w" frameborder="0" allowfullscreen></iframe>
@sameronline
Copy link
Author

ate_youtube
sites\default\modules\AllianceEnhanced\ate_youtube

  • Custom formatter
  • Form to change settings for widht and hieght

use ate_qqform module as example (see the hook_menu) and the form with it

sample code is here:
https://gist.github.com/1435978
http://drupal.org/node/1046864
http://api.drupal.org/api/drupal/modules--system--system.module/function/system_settings_form/6

make refresh everytime you change the formatter settings or anything in the hook

  • access the display suite url for test at:
    /admin/build/ds/layout/appliance/test
  • to view the test display at:
    node/15017/ds/test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment