view_modes_display.pages.inc in View Modes Display 7
File
view_modes_display.pages.inc
View source
<?php
function view_modes_display_preview_entity($entity, $entity_type) {
$entity_info = entity_get_info($entity_type);
$view_modes = $entity_info['view modes'];
if ($entity_info['entity keys']['bundle']) {
$bundle = $entity->{$entity_info['entity keys']['bundle']};
}
else {
$bundle = $entity_type;
}
$view_mode_settings = field_view_mode_settings($entity_type, $bundle);
$build = array();
foreach ($view_modes as $view_mode_name => $view_mode_info) {
if (!empty($view_mode_settings[$view_mode_name]['custom_settings'])) {
$build_add = entity_view($entity_type, array(
$entity,
), $view_mode_name);
$build_add['#prefix'] = '<div class="view-mode-list-item view-mode-list-item-' . $view_mode_name . '"><h1>' . $view_mode_info['label'] . '</h1>';
$build_add['#suffix'] = '</div>';
$build[] = $build_add;
}
}
if (module_exists('field_ui') && empty($build)) {
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
return array(
'#prefix' => '<div class="messages warning">',
'#markup' => t('No custom view modes can be found for this entity. Only view modes that have custom display settings are shown in the preview. !manage', array(
'!manage' => l(t('Manage display settings.'), $admin_path . '/display'),
)),
'#suffix' => '</div>',
);
}
return $build;
}