Skip to main content
Notice removed Draw attention by AjitS
Bounty Ended with goron's answer chosen by AjitS
Question Protected by avpaderno
added 131 characters in body
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73

I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page). snap

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.

I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page). snap

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.

I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page). snap

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.

added 166 characters in body
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73

I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page). snap

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 pseudo= code
ifdb_query('SELECT n.nid from {node_revision} n WHERE n.nid LIKE :uid',array(number':uid' of=> entriesarg(1))); for current_node_nid >1 
$temp_var = 0;
foreach ($result as $result_item) {
  $temp_var++;
}
//If revisions revisionare present!
else $temp_var>1
//Only one version present if can$temp_var hide== the1
if($temp_var == 1) {
  //menu unset code goes here!...
}

I am looking for the database query and a suitablejust not sure in which hook in whichshould I could implement this logic.

I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page). snap

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

// pseudo code
if (number of entries for current_node_nid >1)
    revision present!
else
    can hide the menu here!

I am looking for the database query and a suitable hook in which I could implement this logic.

I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page). snap

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.

added 556 characters in body
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73

I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page). snap

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

// pseudo code
if (number of entries for current_node_nid >1)
    revision present!
else
    can hide the menu here!

I am looking for the database query and a suitable hook in which I could implement this logic.

I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page). snap

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.

I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page). snap

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

// pseudo code
if (number of entries for current_node_nid >1)
    revision present!
else
    can hide the menu here!

I am looking for the database query and a suitable hook in which I could implement this logic.

added 214 characters in body
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73
Loading
Tweeted twitter.com/#!/StackDrupal/status/228121538887553024
added 17 characters in body
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73
Loading
Notice added Draw attention by AjitS
Bounty Started worth 50 reputation by AjitS
deleted 8 characters in body
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73
Loading
added 8 characters in body
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73
Loading
deleted 7 characters in body
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73
Loading
added 7 characters in body
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73
Loading
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73
Loading