Skip to content

Instantly share code, notes, and snippets.

@flashvnn
Created June 10, 2014 09:29
Show Gist options
  • Select an option

  • Save flashvnn/40b35080fce3ea9dcc0b to your computer and use it in GitHub Desktop.

Select an option

Save flashvnn/40b35080fce3ea9dcc0b to your computer and use it in GitHub Desktop.
Drupal list all node types and view mode
<?php
$node_types = array();
foreach (node_type_get_types() as $type => $item) {
$node_types[$type] = $item->name;
}
$form['type'] = array(
'#type' => 'select',
'#title' => t('Content Type'),
'#options' => $node_types,
'#default_value' => $conf['type'],
'#description' => t('Select content type'),
);
$view_modes = array();
$entity_info = entity_get_info('node');
foreach ($entity_info['view modes'] as $key => $item) {
$view_modes[$key] = $item['label'];
};
$form['view_mode'] = array(
'#type' => 'select',
'#title' => t('View Mode'),
'#options' => $view_modes,
'#default_value' => $conf['view_mode'],
'#description' => t('Select display view mode'),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment