Provide tokens for node url and path (i.e. absolute and relative alias respectively)
gordon - March 14, 2007 - 06:33
| Project: | Token |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Hi,
I am using tokens with the actions module, to create a node review facility so that the system will remind people when nodes are up for review but there seems to be some tokens missing for the node.
[node-body] We may want to have a html version and a pure text version
[node-preview] the same as above.
[node-url] So that when an email is being sent to someone it can contain a link back to the node in question.

#1
Just making the title a little more descriptive.
I'm also not sure the body or preview are part of the spirit of token module.
#2
only eaton knows for sure, but i do think body and url are valid and useful tokens. not sure what preview is.
#3
I take node-preview to be the teaser. Right?
#4
what is the status on this - seems like a good feature.. maybe there is an existing feature?
#5
Basically the status is that building the node body and teaser is expensive (afaik) and token is already maligned as being a performance hit. So, this is more or less postponed like many other expensive tokens until we have a system and benchmarking tests to
1) Provide a token registry with names and associated callbacks
2) Find tokens within the $original and only call the token-builder callbacks for those specific tokens
3) Proves that this is faster with benchmarks
#6
What about a separate issue just for the node's URL, then? Seems like that's pretty cheap and incredibly useful.
#7
In IRC, Eaton voiced support for [url] == absolute URL to the node, [path] == relative drupal path (both care of url(), just depending on the final $absolute arg). He said he's willing to commit that much now. Here are patches for the end of DRUPAL-5 and DRUPAL-6--1 branches. I tested the D5 version (I don't have a D6 test site w/ token setup ATM), but it seems trivial.
#8
I'd rather see these tokens as node-path and node-url so there is no confusion about what the mean in a situations where tokens from multiple realms are being mixed together.
If you agree with the idea then I can tweak/commit.
#9
Works for me. I was just being consistent with everything else -- none of the other node-realm tokens have a "node" prefix (except in their descriptions). But, if you think it's important to use them for these (and not things like [yyyy]) ;) I certainly have no objection. Maybe eaton should weigh in with his thoughts before this lands one way or another, just to be safe?
Thanks,
-Derek
#10
IMO lack of a prefix on things like yyyy is a bug and we shouldn't let that bug's pattern spread to the rest.
But indeed, as you prefer, let's wait for eaton's review ;)
#11
Cool, sounds good to me. FYI: I'm going to be AFK until Sept 1, so if this needs a re-roll, someone else will have to carry the torch for a little while. Thanks.
#12
imo the patch from #7 is really much missing - how to link to a node with url alias else?
simple and really useful!
The patch from #7 for d5 is fine, however for d6 it was broken. I fixed it, re-rolled and tested it -> patch for d6 attached.
#13
Patch token_url_6.patch works great for me with D6. Thanks!
#14
I applied this patch to 6.x-1.x-dev for December 11, 2008, and when I have an email sent when a file is ready to publish, the email still comes over as
Joey at Hootersville Community College %title is ready to publish at %node_url.
Joey = %username - works fine
Hootersville Community College = %site_name - works fine
%title - not so much
%node_url - not so much
Am I using the patch with the correct version of Token? Thanks.
#15
subscribing
#16
I saw that in the new Mar 25 dev version some of the node-related token issues were fixed for comments. I tried it to see if it fixed it for my not-comment-related issue, but it did not.
Again, my issue is that I wish to trigger an email using Workflow/Actions that includes tokens for %site_name, %username, %title, and %node_url. Only the system tokens, %site_name and $username, work for me.
My resulting email is: Hometown Community College writer Joe Student has written a post called %title which is ready to publish at %node_url.
Thanks.
#17
Sigh...still confused. I have one site running 6.x-1.12 and it expands the token %node_url just fine.
Another, seemingly identical site does not. Just tried upgrading to the latest dev, and still does not expand the node url...although other tokens are expanding just fine.
What's the deal with this issue? In terms of token utility, being able to fire an email with a clickable URL would (to my thinking) be one of the top usecases...but even over at groups/token a search on node_url shows nothing much...
Really would love to see an answer to this one.
#18
Sorry: just checking back to see if there are any further thoughts on what makes the node_url token expand (or not) ?
#19
Attached is a patch for 6.x-1.x-dev which is essentially the same as fago's in #12 with the 2 added token for a rendered URL.
I know a URL could be formed using the [title] and [path] tokens from 12, but that relies on the user inputting them to know HTML. This token provides the output from drupal's link function which has the minor added advantage of a title and an active class (if the same URL).
This patch would greatly enhance the new features I'm working on for Relevant Content which will soon allow users to enter Token's to render the output.
Thanks,
Nick
#20
Subscribing, interest in tokens for this sort of purposes, greetings,
Martijn
#21
@ #19 patch: I might be missing something, but (using latest dev version), I get half a patch:
$ patch < token_node_path.patch
patching file token_node.inc
Hunk #1 FAILED at 30.
Hunk #2 succeeded at 181 (offset -10 lines).
1 out of 2 hunks FAILED -- saving rejects to file token_node.inc.rej
advice?
#22
Hmm... I thought I was using the latest dev... Let me try again.
#23
In upgrading from 1.11 to 1.12 and I've lost the [url] token and some emails are being sent with visible HTML tags as if the Content-Type text/html header is missing.
It's been five weeks since #21/#22 -- Any update on this? Have fixes been rolled into dev?
PS, I use the Action_email_role module which requires a patch to token_actions.module (adds function token_actions_send_email_to_role_action() )
#24
I'm very interested in this topic. I'm using "[node:site-url]/node/[node:nid]" at the moment. That works for me, but I'm not able to use a custom path to my nodes. Hoping to have this in the next release :)