function ds_extras_form_node_form_alter in Display Suite 7
Same name and namespace in other branches
- 7.2 modules/ds_extras/ds_extras.module \ds_extras_form_node_form_alter()
Implements hook_form_FORM_ID_alter().
File
- modules/
ds_extras/ ds_extras.module, line 637 - Display Suite extras main functions.
Code
function ds_extras_form_node_form_alter(&$form, $form_state, $form_id) {
// Switch full view mode.
if (user_access('ds_switch ' . $form['#node']->type)) {
$view_mode_settings = field_view_mode_settings('node', $form['#node']->type);
// Get the view modes.
$options = array(
'' => t('Default'),
);
$ds_vm = ds_entity_view_modes('node');
foreach ($ds_vm as $key => $item) {
$overriden = !empty($view_mode_settings[$key]['custom_settings']) ? TRUE : FALSE;
if ($overriden) {
$options[$key] = $item['label'];
}
}
// Only fire if we have more than 1 option.
if (count($options) > 1) {
$node = $form['#node'];
if (!isset($form['ds_extras'])) {
$form['ds_extras'] = array(
'#type' => 'fieldset',
'#title' => t('Display settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#weight' => 100,
);
}
$form['ds_extras']['ds_switch'] = array(
'#type' => 'select',
'#title' => t('View mode'),
'#options' => $options,
'#default_value' => isset($node->ds_switch) ? $node->ds_switch : '',
'#description' => t('Switch to a different view mode to display the full page view of this node.'),
'#weight' => -1,
);
}
}
}