Hi,
at the website that I'm maintaining each revision of a node needs to be reviewed and signed (on real paper) by a supervisor. In order to identify the node's revision without printing out the complete node content I need to form a URL that will link to a given revision of a node at any given time.
Normally this can be done by using the schema "http://[host]/node/[nid]/revisions/[vid]/view". But if a node does only have one revision this will result in an access denied message. So I need to create a second revision of the node to allow the access to that URL. Or use the schema "http://[host]/node/[nid]" which will only display the correct revision as long as no new revision had been added.
I assume that this only happens because the revision tab is hidden when only one revision is available.
Is there any way to generate a URL that will permanently link to the revision of a node that does only have one revision at the time the URL were created?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | revision_link.zip | 663 bytes | mutzel |
| #3 | node.module.patch | 807 bytes | mutzel |
Comments
Comment #1
ainigma32 commentedWell you can write a small module that will point to the latest revision of a node or the first version if there is no revision.
Something like http://www.example.com/latest/[nid] which points to your "latest" module.
The module then retrieves the latest revisions - if any - and forwards to http://www.example.com/node/[nid/view or http://www.example.com/node/[nid]/revisions/[vid]/view
Taking one step back though; have you looked at some of the existing solutions? http://drupal.org/project/revision_moderation comes to mind.
Please post back how that works out for you.
- Arie
Comment #2
mutzel commentedI'm already using the revision_moderation module what does not affect the problem that I have.
I think you misunderstood my first post. I do not need a URL that is redirecting from the node id to the latest revision because it would not link to a distinct node revision. So what I could do is writing a module that will take a revision version id (vid) and will than look if there are more versions to that node so that it can redirect to the URL that would really display that revision. But that would mean that I have to learn how to write such a module.
My first thought had been to simply use a view in oder to generate a list of revisions to the given node id in order to compensate the hidden revision list on nodes that only consist of one revision. But if the user of that view wants to have a full view of that node revision I will still be unable to directly link to that revision. I will only be able to tell him that he needs to click the node link if he had only one revision or the real revision link if there is more than one revision.
The thing is that is problem is so simple and could be solved by just allowing the access to a the revision view URL independent of the count of revisions to that node in the first place. Or am I wrong and it is not that simple?
Comment #3
mutzel commentedI found out that it seems to be that simple. I hacked the core a tiny little bit so that the _node_revision_access function does not check the amount of available revisions anymore. I attached a patch file for this change. Now I'm able to address a node with only one revision using the schema "http://[host]/node/[nid]/revisions/[vid]/view".
That was exactly what I wanted. But could I do this without hacking the Drupal core aswell?
Comment #4
ainigma32 commentedGood for you!
If you want to do this without hacking core you can use hook_menu_alter http://api.drupal.org/api/function/hook_menu_alter/6
That means writing a (tiny) module that implements the access_callback you want.
See here http://drupal.org/node/246039 for some example mini modules.
Will that work for you?
- Arie
Comment #5
mutzel commentedThank you very much for that hint!
I made a mini module as you suggested and it is working like a charm. I attached the code of that module so that anyone can use it.
Maybe someone with a bit more module development experience than I have can review the code?
Comment #6
mdupontIssue fixed. Closing.