Posted by TimG1 on March 4, 2011 at 9:25pm
5 followers
Jump to:
| Project: | Revisioning |
| Version: | 6.x-3.11 |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | RdeBoer |
| Status: | closed (fixed) |
Issue Summary
Hello everyone,
I'm trying to link to the newest/pending revision through Views and I can't seem to find out how.
For example say my nid = 123, my current published vid = 456, and my submitted pending review vid = 789 then how do I link to this page within my View Fields area?
http://www.example.com/node/123/revisions/789/view
I don't see the proper field to get the latest/pending revision vid. I'm looking for something along the lines of Node: Pending vid.
Thanks for reading.
-Tim
Comments
#1
I'm searching for something similar to that, when you found something let me know...
Thanks
#2
Hi,
You don't have to do it through Views, you can use your normal link to the node as produced in the View, eg http://www.example.com/node/123. Then you configure what happens when people click on it (i.e. either load the current or latest revision) through Revisioning. You do this at Admin >>Site Configuration >> Revisioning.
The downside (or is it an upside?) is that clicking on any link that points to http://www.example.com/node/123 anywhere on your site will take you to the latest revision.
Alternatively in your view create links to the /revisions tab, eg http://www.example.com/node/123/revisions, from which they can then pick the revision they want.
If none of this what your are after and only want them to go this particular pending revision then this will require some extra Revisioning/Views code, I think.
Rik
#3
+1
Perhaps with http://drupal.org/project/views_php? We would just need a snippet to get the latest revision for a node :)
Being able to have a link from a View straight to the latest revision saves some clicking, we can skip the revisions page.
#4
Oh I think I even found the snippet :)
http://drupal.stackexchange.com/questions/1010/how-can-i-obtain-the-late...
No need for a custom module though, just a Views PHP field...
#5
@giorgio:
Thanks for the link to http://drupal.stackexchange.com -- I didn't know this site, let alone that my module got mentioning!
Yep, the "Views PHP" module will work.
I would use a different code-snippet for the Global PHP field tough. This is what I just did. I tested this in D7, but D6 will be identical.
I installed and enabled Views PHP.
I then edited the existing "Content summary" View to add a "Global PHP" field.
In the "output code" section of the Global PHP form I entered the following:
<?php$nid = $row->nid;
$vid = revisioning_get_latest_revision_id($nid);
echo "<a href='node/$nid/revisions/$vid/edit'>Edit latest</a>";
?>
This will create a colum in your View that contains for each piece of conent listed a link to edit the latest revision of that content (will be the current revision if the content has no pending revisions). If you want a link to view (rather than edit) the latest revision, just change the word "edit" to "view" in the code snippet above.
#6
Lovely, thanks Rik.
#7
Just one question, lets say if there is no revision yet, the edit link should go to create new page, it would look like this right?
<?php$nid = $data->nid;
$vid = revisioning_get_latest_revision_id($nid);
if ($data->vid == $vid)
echo
echo "<a href='node/$nid/edit'>Edit</a>";
else
echo "<a href='node/$nid/revisions/$vid/edit'>Edit latest</a>";
?>
PS: replace $nid with $node->vid, also $row did not contain the node object for me in views php only $data.
#8
URLs of the form 'node/%/revisions/%/edit don't work for content that is not subject to moderation, at least not in D7. So for D7 (or for D6, if you want to have different link texts for the two cases) you'd use something like this:
<?php$nid = $row->nid; // $data->nid in D6 ?
$latest_vid = revisioning_get_latest_revision_id($nid);
$current_vid = revisioning_get_current_node_revision_id($nid);
if ($current_vid == $latest_vid) {
echo "<a href='node/$nid/edit'>Edit current</a>";
} else {
echo "<a href='node/$nid/revisions/$latest_vid/edit'>Edit pending</a>";
}
?>
#9
Automatically closed -- issue fixed for 2 weeks with no activity.