I have a website I am working on that has a normal theme and a mobile theme. When the mobile theme is used I want to use a different View Mode. I just can't figure out how to change the view mode when the mobile theme is used. I was thinking in a PHP template override I could specify the node view mode before being rendered. Either that or a module that checks for the mobile them and changes the view mode of all nodes to the mobile view mode.

Any help would be appreciated.

Thanks!

Comments

poeticninja’s picture

Ok I found a few items that get my closer to what I am needing. I just can't seem to get it to work. I am testing this idea with the teaser for now.

<?php
$rendered_teaser = render(node_view(node_load($nid), 'teaser'));
?>

I found that information be reading the links below. I am still not able to get it to work but close. For some reason I get errors. I think it has to do with me placing it in the node.tpl.php and the page.tpl.php template file. Instead of $nid i used node 2 for a test and that worked perfectly. The problem is I need the node I am currently on.

http://drupal.org/node/985022
http://drupal.stackexchange.com/questions/36028/getting-the-auto-summary...
http://drupal.stackexchange.com/questions/23961/print-result-of-a-node-load

poeticninja’s picture

And I got it working. Any comments appreciated. I placed this on the top of the page.tpl.php.

<?php 
$nid = $node->nid;
$rendered_teaser = render(node_view(node_load($nid), 'teaser'));
?>

And I placed the print rendered_teaser where I wanted the node view to be printed.

<?php 
print $rendered_teaser
?>
kaizerking’s picture

It seems you want to get various page sizes depending on the client mobile or PC or tablet.
If your only concern is that then you can use omega theme, where you can design responsive themes.
initially i didn't know that(I am very bad in in theming).A responsive theme adjusts the design according to the client display system.try it if you are looking for such function

dave reid’s picture

Status: Active » Fixed

You should actually update to the latest version of core and use the new hook_entity_view_mode_alter().

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.