0

I have a switch statement in my content type tpl file for 2 different view modes:

<?php 
switch ($view_mode) {
case 'full' :
?>

//content for full view mode here

<?php break;
case 'custom-display-mode' : ?>

//content for custom display mode view mode here

<?php break;                
} ?>

How can I print the teaser view mode within full display mode? Can I print it out in the same way you can print fileds in a tpl file?

<?php 
switch ($view_mode) {
case 'full' :
?>

//content for full view mode here
//********* also print teaser view mode here **********

<?php break;
case 'custom-display-mode' : ?>

//content for custom display mode view mode here

<?php break;                
} ?>
2
  • This is so illogical it doesnt make sense. Revise your strategy...
    – Alex Gill
    Commented May 10, 2013 at 14:29
  • The teaser view only shows a few fields and styles them in a custom way. Its used by a view and I also need it to appear in a section in the default node page. So whats illogical about that...?
    – Evanss
    Commented May 10, 2013 at 14:58

1 Answer 1

0

Are you trying to print full display mode + teaser mode under full display mode? You can always render any display mode directly using node_view as

node_view($node, $view_mode = 'full', $langcode = NULL)

or with your example:

switch ($view_mode) {
case 'full' :

//content for full view mode here

$rendered_teaser = render(node_view(node_load($nid), 'teaser'));
print $rendered_teaser;

...

I would also recommend breaking your display mode templates out into separate files to simplify management. If your full mode should be the same as your teaser then using this method you can always just symbolically link the files on your server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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