0

I have a content type "X", and would like to have 2 different view mode per node(I guess it should be 2 different url per node: /node/1 & node/1/summary). I'm not sure is it possible, but I want to make a view that list node of content type "X", each node has 2 links(2 fields), they are link to view mode 1(some fields) and view mode 2(full).

I have been searching this for day with no luck, and hope someone have done this before.

-- update my question for the confusion : Aug 5, 2015 at 5:pm --
What I really need is to have 2 different views mode pages per node(2 actual page per node), so each node can have their summary page(not a list of teaser mode) and full content page.

  • 1
    Are you asking about displaying nodes of type X, or about listing them? I read your question two times, but I ave no idea... If about both, then please limit yor question to one of them. You can ask second one later all right there is no limit on number of questions one may ask. – Mołot Aug 5 '15 at 20:39
  • See this question, too. – Mołot Aug 5 '15 at 20:41
  • Sorry for the confusion. I actually know how to list node in views and create new mode in content type display. What I really need is to have 2 different views mode pages per node(2 actual pages per node), so each node can have their summary page(not a list of teaser mode) and full content page. Hope this make sense to you. – CocoSkin Aug 5 '15 at 20:55
  • Yes, it does :) Just please edit it directly into your question and then flag my comment as obsolete. – Mołot Aug 5 '15 at 20:56
2

you Could create your own display mode using see this Then you create a menu route using hook_menu, similar to this:

function yourModule_menu() {
$items = array();

$items['node/%node/viewmode2'] = array(
'title' => 'Test',
'page callback' => 'yourModule_page_callback',
'page arguments' => array('node', 1),
'access arguments' => array(1), 
'type' => MENU_CALLBACK,
);

return $items;
}

function yourModule_page_callback($node) {
 // here you render the node with the view mode 2
 $node_view = node_view($node, 'view_mode2_key');
 $rendered_node = drupal_render($node_view);
 return $rendered_node;
}

for the other view mode you could use the default display mode on node/node_id or you could create extra one with same approach

|improve this answer|||||
  • Seem like this is the anwser for me, but I have to try this tomorrow. – CocoSkin Aug 5 '15 at 21:49
0

sam2de has a very good answer. You could also do this without any custom code using Panels. You would create a new Panels page, set the path to be node/%node/viewmode2, then embed a pane of type "rendered node" that renders the node using the view mode you desire.

|improve this answer|||||
0

Found View Mode Page module do the trick. This module can create separate pages for different view modes for a given content type.

How to add a view mode page

  1. Create a content type
  2. Configure a view mode. If you are using Display Suite, or another means of adding view modes, you may need to add a new one.
  3. Go to the "manage display" tab for your content type.
  4. In the "View mode pages" tab, enter your URL pattern for the view mode page.
  5. Save the content type. You may also need to clear the Drupal cache, but the page should be available!
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.