Skip to content

Instantly share code, notes, and snippets.

@opi
Created August 29, 2016 14:37
Show Gist options
  • Save opi/87ea03b28026c43873fc8b4780cc47a7 to your computer and use it in GitHub Desktop.
Save opi/87ea03b28026c43873fc8b4780cc47a7 to your computer and use it in GitHub Desktop.
Drupal 7 custom view mode
<?php
/**
* Implements hook_entity_info_alter().
*
* Add view modes .
*/
function MYMODULE_entity_info_alter(&$entity_info) {
// Add 'listing' view mode
$entity_info['node']['view modes']['listing'] = array(
'label' => t("Listing"),
'custom settings' => FALSE, // Do not enable this view mode for all content types by default
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment