Add a status message indicating if a node has not yet been published
Situation: When a node is not published, you have no visual indication that this is the case. So, frequently, while you are under the impression that the page/blog is fine, the rest of your users will be met with a "Page Not Found" or "Access Denied" page.
Solution: The following simple snippet adds a little banner only for unpublished nodes, stating that the node is yet to be published. This will not be visible during preview either.
Applies to: PHPTemplate themes only. 4.7.0 and possibly earlier.
File: node.tpl.php in your theme directory - The following block of code can be added right at the top if need be:
<?php
//Check if status = 0 (not published) and the current page is not a preview page.
if (!$status && !$preview) {
//$type in the message below adds the type of node [blog/story etc.]
$status_message = '<div class="messages status">This '. $type .' node has not been published.</div>';
}
else {
//This is not an unpublished node -> no status message to display.
$status_message = '';
}
?>Now that we know what to print and when to print it, we just need the where ...
File: node.tpl.php [Same file as above] - The following line of code is best added directly above the line that prints the node content [ $content ]:
<?php print $status_message; ?>