How to add additional display(view mode) for node?

I am using drupal7. I am creating custom article content type. Standart node type supports only two view modes teaser and full view modes.

function mymodule_view($node, $view_mode){if($view_mode =='full'){
         $node->content['#theme']='my_full_node_view_theme';}if($view_mode =='teaser'){
          $node->content['#theme']='my_teaser_node_view_theme';}return $node;}

I have to add some other view options for this node type like :

  • small_box
  • small_box_with_user_pic
  • big_box

and want to render node with code like this

$node = node_load($my_nid);
$output = drupal_render(node_view($node,'big_box'));

thanks for your attention. Any help appreciated.

shareimprove this question
 
 
====
 

first we have to add additional view modes

function customuserblog_entity_info_alter(&$entity_info){
     $entity_info['node']['view modes']['blog_post_big']= array('label'=> t('simple big  teaser'),'custom settings'=> TRUE,);}

// we may attach additional theme functions or templates and add variables

function customuserblog_view($node, $view_mode){if($view_mode =='blog_post_big'){// add some additional variables for template
    $node->content['#theme']='custom_blog_big_teaser_view';}}

// in our hook theme

customuserblog_theme(){'custom_blog_big_teaser_view'= array('render element'=>'form','template'=>'custom-blog-big-teaser-view')}