I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page).
I have created a custom menu Book revisions, with path node/[node:nid]/revisions
using menu token module. It renders http://site-url/4/revisions
with 4
as the node id of current node.
I am using Nice menus module to create the menu block and have placed it on every book page so that user can see the revisions whenever he is on the book page.
When I first create a page, and click on this menu, it gives me Access denied page (I'm logged in as user1). But, the moment I edit the page and save it, it works as expected - showing the different revisions.
Requirement: I want to display "No revisions" instead of "Access denied" to users. How can this be done?
I'm also open to suggestions to hide the menu for the first time, and again show it as soon as a revision of the node is created.
Edit: I find that if a node is not revised (edited), node_revision
table has only one vid
for the nid
of node; and if the node is revised the table contain one vid
per revision.
Using this information and a database query, I think it would be possible to find out whether a node has revision. Something like
$result = db_query('SELECT n.nid from {node_revision} n WHERE n.nid LIKE :uid',array(':uid' => arg(1)));
$temp_var = 0;
foreach ($result as $result_item) {
$temp_var++;
}
//If revisions are present $temp_var>1
//Only one version present if $temp_var == 1
if($temp_var == 1) {
//menu unset code goes here...
}
I am just not sure in which hook should I implement this.
EDIT: I'm using Diff module to enable the users to view the differences in two revisions.