function iframe_field_formatter_view in Iframe 7
Implements hook_field_formatter_view().
field settings = settings from "Feldtyp = field type" for the given generic field in the content-type instance settings = generic settings from iframe-field (specific only in this content-type) ==> take (1) field-settings => overwrite (if set) with (2) instance-settings => overwrite with (3) item-settings
File
- ./
iframe.module, line 344 - Defines an iframe field with all attributes.
Code
function iframe_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
// object_type = node, object = Article-node-object
iframe_debug(2, 'iframe_field_formatter_view', array(
'field' => $field,
'instance' => $instance,
'langcode' => $langcode,
'items' => '...',
'display' => $display,
));
$element = array();
$settings = $instance['settings'] + $field['settings'];
// f-s rules i-s
if (isset($settings['user_register_form'])) {
unset($settings['user_register_form']);
}
# merge for sub-fields: "class"
$settings['class'] = @trim($field['settings']['class'] . " " . $instance['settings']['class']);
$class = $settings['class'];
foreach ($items as $delta => $item) {
$items[$delta]['delta'] = $delta;
$items[$delta]['id'] = drupal_html_id($field['type'] . '-' . $field['field_name'] . '-' . $delta);
$iclass = isset($item['class']) ? $item['class'] : '';
if (isset($settings['expose_class']) && $settings['expose_class'] > 0) {
$items[$delta]['class'] = trim($class . " " . $iclass);
}
else {
$items[$delta]['class'] = trim($class);
}
}
if ($display['type'] == 'iframe_formatter_default') {
foreach ($items as $delta => $item) {
$element[$delta]['#markup'] = iframe_formatter_default_helper($item, $delta);
}
}
elseif ($display['type'] == 'iframe_formatter_only') {
foreach ($items as $delta => $item) {
$element[$delta]['#markup'] = iframe_formatter_only_helper($item, $delta);
}
}
elseif ($display['type'] == 'iframe_formatter_asurl') {
foreach ($items as $delta => $item) {
$element[$delta]['#markup'] = iframe_formatter_asurl_helper($item, $delta);
}
}
elseif ($display['type'] == 'iframe_formatter_asurlwithuri') {
foreach ($items as $delta => $item) {
$element[$delta]['#markup'] = iframe_formatter_asurlwithuri_helper($item, $delta);
}
}
elseif ($display['type'] == 'iframe_formatter_hidden') {
foreach ($items as $delta => $item) {
$element[$delta]['#markup'] = '';
}
}
return $element;
}