Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How could I detect if node type is article (in template.php) but process variables only for teaser of article, not article i full mode. (I have template suggestions so i have node--article-teaser.tpl.php). Like:

if ($node->type == 'article' and inject only if article-teaser.tpl.php)


share|improve this question
up vote 1 down vote accepted

In a preprocess/process function for the node template file, you just need to check the following variables:

  • $variables['teaser'] must be TRUE
  • $variables['node']->type must be 'article'

$variables is the parameter passed to preprocess/process functions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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