As an authorised user having access to both published and unpublished nodes it is impossible to tell the status of a node by just displaying it, this sometimes makes site maintenance more difficult than it has to be.

Does anyone have a method of making node status visible on display, preferably themeable?

I'm on 4.7.3 and using a modified bluemarine-phptemplate theme.

Comments

cog.rusty’s picture

Probably something in node.tpl.php like "if (!$status) print 'unpublished'" or "tag with this css class".

But you can always see them and sort them out in /admin/node.

pwolanin’s picture

there are several ways I can think of right away

1) if you are only using one (or a few) node template files, you could just add code to node.tpl.php like:

  <?php if ($node->status == 0): ?>
    <div class="unpublished-message">This posting is currently unpublished and won't be visible until approved.</div>
  <?php endif; ?>

2) implement a mini module that uses hook_nodeapi() to call drupal_set_message() every time you're looking at an unpublished node.

3) write a mini-module and implement hook_nodeapi to add a message to the node's content (essentially a different route with the same end result as #1- however this might be easier if you have a number of template files).

---
Work: BioRAFT

jvlagsma’s picture

Thanks for your help, this is exactly what I was after. I've used nr 1 and may be extending it a little now that I've seen how to do it.

Scott’s picture

The phptemplate code above works with unpublished comments, too, but you have to change ($node->status == 0) to ($comment->status == 1) and place the code in comment.tpl.php

(Don't ask me why the unpublished status code is 0 for nodes but 1 for comments!)