Skip to content

Instantly share code, notes, and snippets.

@khalib
Created January 22, 2014 21:34
Show Gist options
  • Select an option

  • Save khalib/8567788 to your computer and use it in GitHub Desktop.

Select an option

Save khalib/8567788 to your computer and use it in GitHub Desktop.
Example of how Drupal 7 view mode template variables are set
<?php
function tlr_blog_preprocess_node(&$variables) {
global $user;
$node = $variables['node'];
if ($node->type == 'tlr_blog') {
$blog = new TLRBlog($node->nid);
$account = $blog->get_user();
// Set template variables here for all view modes.
$variables['title'] = $blog->title;
// ...
// Set template variables for specific view modes.
switch ($variables['view_mode']) {
case 'teaser':
// Something specific for teasers.
break;
case 'full':
// Something specific for full nodes.
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment