I am trying to make a new variable for a theme whose name is ntheme. I have defined the following function in template.php.

function ntheme_gnu_preprocess(&$variables) {
  $variables['disclaimer'] = t('Comments are unaythorized. The views expressed are those of the comment author.');

I used $disclaimer in the comment-wrapper.tpl.php template file.

<div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if ($content['comments'] && $node->type != 'forum'): ?>
    <?php print render($title_prefix); ?>
    <h2 class="title"><?php print t('Comments'); ?></h2>
    <?php print render($title_suffix); ?>
  <?php endif; ?>
  <?php print render($content['comments']); ?>
  <?php if ($content['comment_form']): ?>
    <h2 class="title comment-form"><?php print t('Add new comment'); ?></h2>
    <?php print render($content['comment_form']); ?>
  <?php endif; ?>
  <p><?php print $disclaimer; ?></p>

I get the following warning.

Notice: Undefined variable: disclaimer in include() (line 39 of C:\wamp\www\drupal\sites\all\themes\ntheme\templates\comment-wrapper.tpl.php).

What am I doing wrong?

  • your theme is is ntheme then use ntheme_preprocess
    – monymirza
    Jul 14, 2013 at 6:54
  • Try out ntheme_preprocess_page
    – monymirza
    Jul 14, 2013 at 6:55

2 Answers 2


You should use THEME_preprocess_comment_wrapper(&$variables) to alter comment wrapper variables.


Each template file has its own preprocess/process functions. If <theme> is the theme identifier for the theme function, then <module_name>_preprocess_<theme>(), <theme_name>_preprocess_<theme>(), <module_name>_process_<theme>(), and <theme_name>_process_<theme>() are the function names for the preprocess/process functions.

In this case, ntheme_gnu_preprocess() would not be a preprocess function, since it doesn't follow the schema Drupal adoptes for preprocess/process functions: ntheme_gnu is not the short name of the theme.

ntheme_preprocess(&$variables, $hook) would be invoked, but for every theme function / theme template used from Drupal; if you need to use the preprocess function just for the comment-wrapper.tpl.php template file, then you should use ntheme_preprocess_comment_wrapper().

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.