Created
June 10, 2014 09:29
-
-
Save flashvnn/40b35080fce3ea9dcc0b to your computer and use it in GitHub Desktop.
Drupal list all node types and view mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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