Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#11 | revisioning-add-latest-vid-1081804-11.patch | 2.5 KB | cecrs |
Comments
Comment #1
MohamedAli CreditAttribution: MohamedAli commentedI'm searching for something similar to that, when you found something let me know...
Thanks
Comment #2
RdeBoerHi,
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
Comment #3
giorgio79 CreditAttribution: giorgio79 commented+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.
Comment #4
giorgio79 CreditAttribution: giorgio79 commentedOh 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...
Comment #5
RdeBoer@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:
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.
Comment #6
giorgio79 CreditAttribution: giorgio79 commentedLovely, thanks Rik.
Comment #7
giorgio79 CreditAttribution: giorgio79 commentedJust 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?
PS: replace $nid with $node->vid, also $row did not contain the node object for me in views php only $data.
Comment #8
RdeBoerURLs 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:
Comment #11
cecrs CreditAttribution: cecrs commentedI had this same need, so I wrote a field handler to grab the latest vid, as I didn't particularly wish to use Views PHP. Patch is attached, against 6.x-3.x dev branch.
Comment #12
RdeBoerThanks for the patch, cecrs!
Rik
Comment #13
RdeBoerOnly doing bug fixes and patches for D6. Sorry.