Need some help with your project? Contact me

How to hide content in your node template in certain View Modes

This is a quick workaround if you want to add some content to your Node template (node.tpl.php) that you only want to display on a particular View Mode (such as Teaser or Full View).

It is in fact a simple .php conditional. Let’s say you want content to appear only in the Teaser view mode:

if ($view_mode == 'teaser') {
  // content you want to display

For the Full View mode, you just replace teaser with full.

Hope this helps.

Add new comment

You can post comments in Markdown and basic HTML tags.
For code blocks, wrap your code within '~~~'. For example:
$var = 'my variable';