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.
I am not sure if this is a bug report or a feature request.
CCK link can take tokens for titles.
Can it also take tokens for urls?
It would be very beneficial if I want to create default urls for users.
Chris
Comment | File | Size | Author |
---|---|---|---|
#36 | 412404-link.module-tokenindomain.patch | 1.08 KB | neilnz |
Comments
Comment #1
presleyd CreditAttribution: presleyd commentedHmmm I was just wondering about this myself, I was sure an older version used to do this.
Comment #2
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedComment #3
jcfiala CreditAttribution: jcfiala commentedWell, at the moment it sounds like new functionality. At the moment I'm concentrating on getting 6.x-2.6 out the door (see the shiny beta release? Please test!) but I'm welcome to hearing more about what you're interested in this doing. I haven't used the token functionality that is in link yet, so I'm not sure how that works in titles yet.
Comment #4
szegedi CreditAttribution: szegedi commentedHello, I try to solve a similar problem, but that would be the best way, if token can be added to url, because I try to find way to add variables (ex: node id) to link url dinamically, but the only way is php code... a module, or a patch to link module would be better...
Thnx
Szg
Comment #5
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedFrom what I read, tokens in titles are fine.
But I would like to have tokens accessible for the url.
For example, I would like to setup a cck link, my profile. the cck field would be user/[author-id] and when the link is used, the proper replacement for [author-id] would happen.
Simple use case, but I think it gets the point accross
Comment #6
minus CreditAttribution: minus commentedI am also very interested in a function like this
I'm working on a project where I need a field with a default url. The client fills out the form, a combination of the default url and what the user submits should be the final url.
Default setting for the link field should be something like this: http://www.link.com/#, when the user submits his form, the field should be http://www.link.com/#*****, and displayed on the node like "go to website". I have tried to solve this with link 6.x-2.5 ut with no luck.
Really need this function and hope you can help me :)
Morten
Comment #7
minus CreditAttribution: minus commentedam I just stupid or can this be done differently? :D
Comment #8
jcfiala CreditAttribution: jcfiala commentedI don't know what you mean, and I know I don't know you well enough to tell if you're stupid. :)
That said, there's usually more than one way to do something, especially if you're willing to roll up your sleaves and do some custom coding. using hook_nodeapi and an appropriate hook, you could change the value of the url when it's being displayed on a given context. Similarly, you could try doing something like that in the theme layer, overriding the node template involved.
Although I think the idea of having a token-replace in a url is a neat one, it's not currently a prioritiy to me - getting the module released at 6.x-2.6 is top priority for me, and then I want to fix up my DME module for an official 6.x release.
Of course, if someone wants to submit a patch...
Comment #9
minus CreditAttribution: minus commented:D
I just want a field in my form where the user submits a number, when the user submits his form the number he entered will be part of an url that is showed as a link on his node. It's like a combination of a default url and what the user submits. If the default url is http://www.link.com/ it will be http://www.link.com/123 after the user has submitted his form. Possible?
I have no php skills at all :-/
Comment #10
minus CreditAttribution: minus commentedI fixed this with views:
content field and select "Output this field as a link", add the url and Replacement pattern: http://example.com/[field_your_field__value]
Comment #11
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedis [field_your_field_value] a token or a specific field.
My original idea was around tokens in link.
Thanks,
C
Comment #12
minus CreditAttribution: minus commentedits a specific field, sry :(
Comment #13
k3vin CreditAttribution: k3vin commented+1
Comment #14
k3vin CreditAttribution: k3vin commented@minus: You don't really need an extra content field [field_your_field__value] to add a reference argument to a link. The easiest way is just use the custom cck link field and put your link there manually. For example reviews/209
With token like reviews/[nid] would be nice. So the user don't care about this field and will see only the final link. I hope this feature will implemented soon.
Edit: I see that token already works with this option in link url fields only for the node edit form:
[x] Allow user-entered tokens
Checking will allow users to enter tokens in URLs and Titles on the node edit form. This does not affect the field settings on this page.
Another way to create custom links is to use the "custom links" module :) ->http://drupal.org/project/custom_links
This module supports tokens in URL. So it's very flexible and easy to create automatically links.
Comment #15
minus CreditAttribution: minus commentedIn my case, the content type is a car-ad, where users can create ad's for their cars and boats. The link field(content-field) is the "number-plate"'s number, when the user fill this out and the node is being viewd, the field is a link to the an official database where users can check the car for financial issues. Id that can be done with custom_links I'm pleased.
Comment #16
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI read that I could use custom links module to add a token to the actual URL. But does that module setup a cck so I can theme each link individually? Or does it just add an additional link to $node->link?
Thanks,
Chris
Comment #17
k3vin CreditAttribution: k3vin commentedIt adds additional links to "$node->link" for nodetypes. I think you can theme these links individually. Usually they are display after the body content.
Comment #18
tinem CreditAttribution: tinem commentedThink I have the same problem as mentioned here but can't figure out how to solve it. Hope some one can help with code to use, please?
CCK field as link - why is [nid] not functioning dynamic?
On this post http://www.tinemuller.dk/drupal/node/1139 in the link after New Find it on: http://www.tinemuller.dk/drupal/node/1097/?querynid=[nid] I can't understand why [nid] is NOT functioning - do you?
If you change [nid] to the node 1139 like this http://www.tinemuller.dk/drupal/node/1097/?querynid=1139 it's functioning. Have used days to solve this without success but I'm sure it can be done.
I have made this selections http://www.tinemuller.dk/drupal/div/New_Find_it_on.gif
Do I need to make it with some PHP code and if yes can you suggest the PHP code?
Or do I need to make it selecting some of the possibilities further down on the site where Token is mentioned?
Comment #19
tinem CreditAttribution: tinem commentedComment #20
bredi CreditAttribution: bredi commentedBUMP
I have the same issue/request.
I tried enabling "Allow Tokens" as well. But it doesn't work.
thanks
Comment #21
marcoBauli CreditAttribution: marcoBauli commentedsimilarly here "Allow user-entered tokens" does not have any effect.. opened a separated issue at http://drupal.org/node/561084
Comment #22
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedi am taking a look at the cck link and I see that I can add in a default cck link value. I was going to use php to try and fill in the value
user/uid
but how do I specify uid of node author:
$node->uid
Do i have to perform a node_load? does this work when someone is submitting the node for the first time?
Comment #23
tinem CreditAttribution: tinem commented#18
If this will never get to functioning with token [nid] what can be used instead?
Comment #24
jcfiala CreditAttribution: jcfiala commentedOkay, I wrote a couple of automated tests using tokens in the url, and it works fine. I used the [type] token, which returns the node's type, and the [author-uid] token, which returns the author of the node's uid, which should handle things for generating links to users and the like.
If you're continuing to have this problem with the latest version, I'll need more detail about how you've set up your field and what you're using as the link content.
Comment #25
mattwmc CreditAttribution: mattwmc commentedWell, I'm looking for tokens in the url as well.
Specifically the file name.
Something like this:
Is this possible?
Comment #26
jcfiala CreditAttribution: jcfiala commentedIt should be, assuming [field_image-filefield-filename] is a valid token. I'm feeding the value of the feed through the 'node' tokens from the token module, so if my tests work, this should too.
Again, assuming that that is a valid token.
Comment #27
mattwmc CreditAttribution: mattwmc commentedYes its valid, but it just returns the text: [field_image-filefield-filename] and not the filename.
Do I need to enable something to get it to work in cck fields?
Thanks for the reply.
Comment #28
jcfiala CreditAttribution: jcfiala commentedYes its valid, but it just returns the text: [field_image-filefield-filename] and not the filename.
Do I need to enable something to get it to work in cck fields?
Well, do you have the Token module enabled? And did you check the 'Enable Tokens' checkbox in the field configuration form? Those are the only two things that need to be set for it to work.
Comment #29
mattwmc CreditAttribution: mattwmc commented"And did you check the 'Enable Tokens' checkbox in the field configuration form?"
Where is this located? I don't see it under "Manage Fields."
Thanks for helping out.
Comment #30
jcfiala CreditAttribution: jcfiala commentedUnder the 'Manage Fields' tab for the node type, you click on the field's 'Configure' link, and that takes you to the form where you can set things - about halfway down the page should be an 'Enable Tokens' checkbox.
If you can't see the Enable Tokens checkbox, then you don't have the token module enabled.
Comment #31
mattwmc CreditAttribution: mattwmc commentedI still don't see it and Token is enabled.
Here are the screen shots. Is it missing or am I just missing it?
Screen Shot of Mod Token enabled: http://www.cosmicbooknews.com/images/tokenenabled.jpg
Screen Shot of CCK field: http://www.cosmicbooknews.com/images/dpfield.jpg
Comment #32
jcfiala CreditAttribution: jcfiala commented@mattwmc: You're showing me the field of the 'Link Image' widget type. That's not provided by the Link module - you're in the wrong issue queue. I'm guessing this is some kind of filefield thing?
Comment #33
mattwmc CreditAttribution: mattwmc commentedOh, I thought this was for cck filefield links? Isn't that image field a file field?? I'm confused, lol.
So I suppose tokens can't be used then?
Oh, fudge. I see "project" says link now. I was just looking at the title of the thread I found while searching. Sorry, for being a pain. Newbie here.
Comment #34
jcfiala CreditAttribution: jcfiala commentedWell, thank you for making a screen shot - that was helpful to realize what was wrong!
Comment #35
mattwmc CreditAttribution: mattwmc commentedlol. Yeah, sometimes I don't know the correct "lingo" and use screen shots to get my point across -
Especially when I am trying to wrap my head around all these modules!
Gotta say, drupal rocks though! Just need a bit of patience! ha!
Comment #36
neilnz CreditAttribution: neilnz commentedSorry if I'm hijacking this issue a bit, but I'm having a problem that I can't use a token as part of the domain, as it fails the URL validation in link_validate_url() because of the token square brackets in the domain. Otherwise token substitution is working fine as-is (eg. in GET params).
I've attached a patch I applied that substitutes the tokens on node save before attempting to validate the URL. This fixes the problem for me, and in theory provides stronger validation than at present, as it checks what's in the token can form a valid URL.
Comment #37
nravens CreditAttribution: nravens commentedI need to do something similar but don't have a clue how to do this... I have a content type called accommodation with a link field that should link to an external URL; https://www.nightsbridge.co.za/bridge/Search?bbid=*with a user entered page ID here*
This user page ID is a 5 digit number that completes the URL and this completed URL will go to the user's page on the external site.... The CCK link field only needs to have the 5 digit number entered to be added automatically to the first part of the hidden or uneditable URL. Then I also need to add another static/fixed 2 digit code (also hidden) after the user's 5 digit code... The 2 digit number is my affiliate code for the external site...
I've created a content type template, so is it possible to add some php code to achieve this? or can I do it with the link module? I don't know php really so don't know how to construct something like this in the page template...
Any advice?
Comment #38
Summit CreditAttribution: Summit commentedSubscribing for #36, #37 is a new issue, right?
greetings, Martijn
Comment #39
3dloco CreditAttribution: 3dloco commentedThanks a lot Neilnz!
#36 worked for me (I am able to use tokens for the url).
Comment #40
neilnz CreditAttribution: neilnz commented@3dloco, if it's all working out well for you, could you RTBC this issue for me?
Would be nice to get #36 upstreamed.
Comment #41
3dloco CreditAttribution: 3dloco commented:) thanks
Comment #42
jcfiala CreditAttribution: jcfiala commentedWell, for one, I'd rather you created a new ticket than bring this one to life.
For another, I'm not really sure why we need this, and having the token be evaluated during the node validation instead of when the node is displayed is a little weird. How often do people need to have a token in the host portion of the link? Why would you need to do that?
Comment #43
neilnz CreditAttribution: neilnz commented@jcfiala, the reason I needed it was so that our site's content editors could create links in prod or dev or wherever and have them point to the right place. Our site is part of a network of other sites that all exist in various environments, so we have a custom environment token that they can put in links to test them in a given environment, eg:
Link URL: http://[environment].mysite.example.com/some/path/to/somewhere
The problem is that this causes the URL to appear invalid, unless you validate it at least for the environment it was saved for (or substitute any tokens for some string that will always validate).
Note these links are going to other non-Drupal sites, so can't be node references or paths.
Comment #44
izmeez CreditAttribution: izmeez commented@neilnz Comment #43 sounds close to what I am looking for and I am wondering if the link module by itself or in conjunction with others will do the job. I need to create a menu item that links to a static site and have it work relatively so it works on both the live and dev site and in a multi-site setup.
the link url is http://example.com/sites/example.com/html/content.htm
I imagine the link url will end up like
http://[environment]/sites/[environment]/html/content.htm
or
http://[sitename]/sites/[sitename]/html/content.htm
Is this possible?
Comment #45
greta_drupal CreditAttribution: greta_drupal commentedTokens for URLs would be a great plus (actually an expected functionality). Great for making dynamic links to social media sites, for example.
Comment #46
dqdDear followers of this issue: 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, conflicting with each other randomly. I think, the right way is to find a maybe more complex but all embracing new 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. This will surely lead to a new branch