It seems like token in URL paths are not changed, cause I got this error: "Not a valid URL." while using token like [current-user:uid].
When I'm using the actual number everything works properly.
It works fine in title field also.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | link-1047444.patch | 11.21 KB | sweetchuck |
Comments
Comment #1
jcfiala commentedSome tokens will now work with that, but others, such as tokens which provide an entire url, won't. I'm not sure what to do with this yet. I don't think there were any similar tokens that returned an entire url before.
Comment #2
krembo commentedThanks. I'll check the update.
Comment #3
jcfiala commentedWell, it's been a month and I haven't heard back, so I'm going to nudge this to fixed. krembo, if this is still a problem, feel free to re-open this ticket.
Comment #5
Barfly commentedIt's not fixed ,
when i use the token [current-page:url] in the field url the function "link_validate_url" return false.
link_validate_url should be desactivate(or work differently) when token is available.
In order to use token directly in url field i comment those lines:
it's pretty crappy but it works ^^
Comment #6
Barfly commentedactive
Comment #7
jcfiala commentedCurrently, we're only doing node tokens on link fields - I don't have any idea where the [current-page:url] token is coming from - I can't find it searching the code base, so I don't even know how to include it. But that's where the problem is.
Can you tell me which module you installed that provides the current-page:url token?
Comment #8
jcfiala commentedAfter further looking, I found that [current-page:url] token is provided by the Token module. Fair enough.
But how are you using this token, that couldn't be handled by node/[node:nid]?
Comment #9
Barfly commentedIn fact i use [current-page:url] because i want A="sub-sub-sub-node" link to B="sub-sub-sub-sub-node" ^^
the links are on "A nodes" and "B nodes" have almost the same alias as A.
with [current-page:url] , i just have to write this URL : "[current-page:url]-aliasForAll-B"
Comment #10
sweetchuckToken replacement are in _link_sanitize(). It is only called from link_field_prepare_view().
The link_field_validate() does not replace tokens before validate the URL.
The other problem is the entity object always introduced as node to the token_replace().
Maybe the token_replace cannot be used if the $entity_info['token type'] is not filled.
Comment #11
robbiePie commentedCould someone please provide this patch update as a usable module? I am trying to link to the content authors profile2 page. Using the token module I can enter [node:author:my-profile:url] into the Static Title field and it resolves to the url perfectly, but in the 'Default URL' the system returns "Not a valid URL".
This seems like a pretty big issue.
Comment #12
robbiePie commentedSweetchuck,
Thanks for providing the patch. I ran " patch < link-1047444.patch " in the same directory as the link-alpha release and it gave me two reject chunks. I took a look at the .rej file and added what didnt make it into the link.module file. After this I get no php notices at the top, but I still get the "Not a valid Url" message after adding a token to link to the content specific profile page for the author.
Any pointers where to start? Thanks!
Comment #13
sweetchuck@robbiePie Patch is applicable on the latest version in the repository.
So you need a copy of the repo:
git clone --branch 7.x-1.x http://git.drupal.org/project/link.gitand
git apply -v [patchname.patch]More information: http://drupal.org/project/link/git-instructions
Comment #14
robbiePie commentedThanks! Works great now!
Comment #15
tuwebo commentedThaks Sweetchuck!
It also works great for me!
Comment #16
kolier commented@Sweetchuck
If site is using some module like http://drupal.org/project/field_collection together, your patch will conflict.
Will cause different result on different entity_type.
Comment #17
dqdDear followers of this issue: But please read the project page info of link module for further validation issues. There is already an issue to collect and discuss all possible validation scenarios in general. That's why I will mark this one here as duplicate. I need all concentration inside the ONE and only discussion to move forward. After a D7 implementation we will provide a D6 backport.
Explanation: There are too many corner cases and validation wishes of users to implement them all serially one after the other. We would have a 40 lines cluttered settings form for validation methods only conflicting each other. I think, the right way is to find a maybe more complex but all embracing configuration method, which lets the admin better decide how and when to validate the url. Including a good description which helps to set it up.
Comment #18
m4oliveiThat's fine that the bit about the replacement as it relates to the validation is pushed off into another ticket. However, that other ticket does not cover the issue where the token replacement supports the node entity only.
In my case, the issue occurs when you add a link field to a profile2 entity, and then use the tokens provided by entity_token.module in the Static title option. Because link.module hardcodes its the data available as node data, they don't get replaced.
I would imagine this would be an issue when link fields are used in this manner on other entities as well: user, taxonomy_term, etc.
Comment #19
jcfiala commentedIn my case, the issue occurs when you add a link field to a profile2 entity, and then use the tokens provided by entity_token.module in the Static title option. Because link.module hardcodes its the data available as node data, they don't get replaced.
Can you give more data as what's going on and what's wrong? Or even better, a patch that fixes it? I'm not sure what you mean by 'hardcodes its the data available as node data' - can you explain more?
Comment #20
m4oliveiSure, let me explain a simplified case without profile2.module. Here are the steps to reproduce the issue:
On a stock D7 with token and link module installed and enabled:
-Add a link field to the user entity (Configuration > Account Settings > Manage Fields)
-On the settings for the link field, choose Static Title for the Link Title.
-In the Static title textfield, enter [user:name]'s website (this is one of the reported tokens available).
-Save
-Edit a user account on your site. Enter a URL for the link field.
-Save
-View the account. Note that it is rendered as "[user:name]'s website". The token is not expanded.
After stepping through the code, the reason seems to be that on line 494 of link.module (7.x-1.0), the $data parameter that you pass to token_replace() keys the data as a 'node' entity regardless of whether it is in fact a node or not. When token module goes to replace the tokens, it looks for $data['user'], can't find it and thus can't do the replacement. Thus this piece of code is entity-unaware and only tailors to nodes.
I believe the patch in #10 attempts to solve this issue, but is mixed in with the validation related fixes. I don't have time to patch it now. I'd start at #10 though.
Comment #21
mgriebe commentedWhat's the status here?
Comment #22
jcfiala commentedOkay, that's an _awesome_ explanation in #20. Thank you.
Comment #23
jcfiala commentedAlright, I've picked out bits from the patch in #10, and it seems to work. I've committed this to 7.x-1.x, and it should be available in 7.x-1.x-dev shortly.