I'm using the Basic theme, and I get the following error when I refresh my site.

Notice: Undefined variable: unpublished in include() (line 18 of /Users/me/Projects/mysite/httdocs/sites/all/themes/mytheme/templates/node.tpl.php).

The line that is caused the notice is the following one.

    <?php if ($unpublished): ?>
      <p class="unpublished"><?php print t('Unpublished'); ?></p>
    <?php endif; ?>
<?php endif; ?>

I don't understand this error. How can I fix it?


1 Answer 1


Try if ($node->status == 0) instead of if ($unpublished).

This may be happening because the variable is not set correctly in a hook_preprocess_node() implementation of the theme; you may also want to check the template.php file in your theme for these hooks.

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.