By jvlagsma on
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
Probably something in
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.
there are several ways I can
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:
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
unpublished message works
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.
Unpublished comments
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!)