Closed (fixed)
Project:
Location
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Feb 2011 at 12:43 UTC
Updated:
8 Nov 2013 at 00:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tonycpsu commentedSubscribing
Comment #2
rooby commentedMarked #1097356: Provide location tokens as duplicate of this.
Comment #3
Anonymous (not verified) commentedHas this been solved? I still don't see any tokens in the URL aliases.
+
Comment #4
j_ten_man commentedHere is the file that handles location tokens. Just drop this in the location module and it rename it to location.tokens.inc (remove the .txt extension). Clear your cache and it should work. To fully clean up the old code, you should delete the location.token.inc file and remove the calls made to it in the location.module.
Comment #5
Anonymous (not verified) commentedWorks like a charm!
Thanks j_ten_man.
Comment #6
podarokcan You provide a patch in git format?
Comment #7
j_ten_man commentedHopefully I did that right.
Comment #8
beckyjohnson commentedWhen I added this file, I got tokens that looked like this: [node:location:city:?] and consequently, that didn't work......
I wonder if this is a problem with old code lingering around. What files do I need to delete old code from? It was unclear for me, when I read the above.
Comment #9
j_ten_man commentedThis is the new dynamic way for tokens to work. Try using [node:location:city] which is the same as [node:location:city:0] to get the city.
Comment #10
beckyjohnson commentedOK, i'll try it again. I just thought the question mark that was showing up was indicative of a problem...
Comment #11
ipndrmath commentedWhen using either [node:location:city:0] or [node:location:city] I recieve the notice:
The token then does not resolve and leaves me with the token text rather than the token value. I am attempting to use the tokens with Automatic Nodetitles.
Any thoughts? Thanks!
Comment #12
gazwal commentedSubscribing
Comment #13
jboeger commentedsubscribing.
Comment #14
j_ten_man commentedI think this should fix the issue in #11.
Comment #15
bryancasler commentedThanks so much for this. I see the option for [account:location], are we able to do [account:location:city] to get the separate fields?
Comment #16
bryancasler commentedI just tried using [account:location] and only the raw token shows up.
Comment #17
j_ten_man commentedYou'd definitely need to use [account:location:city] or [account:location:name] in order to use location tokens.
[account:location] won't be replaced. You need to go further down.
Comment #18
bryancasler commentedThanks j_ten_man. What would be the full list of those tokens. Is it this?
[account:location:name]
[account:location:street]
[account:location:additional]
[account:location:city]
[account:location:province]
[account:location:postal_code]
[account:location:country]
Comment #19
j_ten_man commented@animelion - all of those you listed plus:
[account:location:province_name]
[account:location:latitude]
[account:location:longitude]
[account:location:country_name]
Comment #20
LTech commentedI've put the code in the file sites/all/modules/location/location.token.inc and deleted the old location/token.inc file.
Then I commented out in sites/all/modules/location/location.module:
/**
* Implements hook_token_values().
function location_token_values($type, $object = NULL) {
require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'location') . '/location.token.inc');
return _location_token_values($type, $object);
}
*/
/**
* Implements hook_token_list().
function location_token_list($type = 'all') {
require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'location') . '/location.token.inc');
return _location_token_list($type);
}
*/
I cleared the cache but I still don't see location: options under URL aliases/patterns replacement patterns -> nodes
I have cck fields locations fields that I want to use in the URL.
What am I doing wrong?
Thanks so much
Comment #21
wprunella commentedDoes this patch only work for Node Location fields? I am using Location CCK and I cannot get this patch to work.
Locations tokens do not show.
There are no error messages.
Comment #22
wprunella commentedFor others who are having trouble with this patch.
Node Locations works.
Location CCK does not work.
Comment #23
LTech commentedThanks for letting us know. Is there anyway to do it with Location CCK?
Comment #24
aniebel commentedJust as an FYI... Not sure if this is relative to this or not but I don't see tokens for individual fields (phone, address, state, etc) in Views after applying this patch.
Comment #25
rubenlor commentedI managed to modify location_cck.module, this is the first step, this is not fine
Comment #26
sol roth commentedAnyone get user location tokens to work correctly?? I'm trying to get them to show up in Panels title (manually set or from pane) and even though I can see "%user:location" in the substitutions menu. It does not show up. I tired drilling down farther into %user:location:city and %user:location:city:0, but those do not show up either.
Comment #27
Refineo commented@rubenlor, the attachment in #25 is in a wrong format. It is probably a modified location_cck.module, not a diff patch (like the patch in #14), isn't it?
Can you please provide a patch in the diff patch format ?
Comment #28
bryancasler commented+1 for anyone who can help with a proper patch
Comment #29
Refineo commentedOK, here is the patch based on the #25 and the latest location_cck.module 7.x-3.x-dev.
This still needs work and cleaning the code.
Comment #30
bryancasler commentedApplied the patch in #29 but I don't think it's workings, or at lease these tokens no longer work.
Comment #31
doublejosh commentedREMOVING, unrelatedComment #32
doublejosh commentedREMOVING, unrelatedComment #33
jghyde commentedI am a bit confused. The attached location.tokens.inc_.txt to #4 fixed my problem. However, this thread is diverging from node location to cck location.
#4 appears to fix the NODE location. As for the rest...
None of the patches patched anything for me. But the patch threw no errors, only silence.
Comment #34
doublejosh commentedMy fault. Please ignore.
Totally unrelated.
Comment #35
miaoulafrite commentedhello there!
any news for location cck and 7.x-3.x-dev?
Comment #36
bnicoll commented#7 - Patch - Brilliant - Thankyou!!!
Comment #37
podarokfrom #36
Comment #38
steven.wichers commentedPatches in #25/#29 for location_cck seem to be just the token code copied from location. The function names aren't correct and have a hard-coded field name.
Comment #39
rooby commentedNo need for porting the patch, it is for drupal 7 only.
Sorry for not looking at this earlier, I will have a proper look later but at first glance:
hook_token_list() and hook_token_values() are drupal 6 functions and are not required in drupal 7.
Drupal 7 only requires, hook_token_info() and hook_tokens().
For an example see the Examples module example - http://drupalcode.org/project/examples.git/blob/refs/heads/7.x-1.x:/toke...
Comment #40
Rechi commentedAny updates on token support for cck location 7.x-3.x?
Thank you for your hard work.
Comment #41
aaronbaumanproblems with patch 29:
Comment #42
LiloLilo commented+1 subscribing for Location CCK tokens support. Any news? Is there a working patch or dev release? Thanks
Comment #43
rooby commented#39 & #41 have still not been addressed since the patch in #29.
Comment #44
rooby commentedI'll put some time in here.
Comment #45
rooby commentedI've done a fair bit of this however it seems we are blocked until this issue is resolved:
#1195874: Need to figure out how to create nested tokens from the array token type
Reason being is that we need a structure like this:
node:locations:value:0:country
user:locations:value:0:province
That kind of structure is not possible with the current token module (array tokens are provided by the token module, they aren't part of core tokens).
If an entity could only have a single location we would be ok but that isn't the case.
I will properly check out the progress of that ticket soon and see what I can do here.
Comment #46
jibus commentedThe patch provided in #14 seems to work for Location node.
Would it be possible to commit this ?
Comment #47
marianojp commentedHi Jibus,
Can Anyone help me? I tried all the patches but still not working.
Comment #48
strykaizerPatch #14 works for me (Used it to add location related data in url alias)
Thx!
Comment #49
Ether commentedAny chance that token support for Location CCK will be in dev version soon ?
Comment #50
jibus commentedAny news on this ?
Comment #51
podarokbot?
Comment #53
podarokthe patch needs reroll
Comment #54
rooby commentedSorry, I somehow missed the old patch in #14. I so wish drupal.org had some sort of flag functionality for bookmarking important issues.
Also, the issue referenced in #45 is unlikely to get fixed any time soon I would say, so maybe an alternative for now could be to implement something like the subscriptions module has, as mentioned in #1195874-26: Need to figure out how to create nested tokens from the array token type.
Unassigning myself as I have not had time to work on this since #45.
Comment #55
jibus commentedThe patch provided in #14 works for the general location module.
The patch #25 & #29 are for the submodule CCK location module and needs some love.
Should we create an other issue regarding tokens in CCK location module ?
Comment #56
podarok#14: token-support-1056154-14.patch queued for re-testing.
Comment #57
podarokto #55
We can handle #25 and ##29 here after #14 commited or if You want to give love for those patches by youself You can create follow-up issues to this )
Comment #58
podarok#14 commited pushed to 7.x-3.x-dev
#25 and #29 still need some love
Thanks!
tagged as Needs test for #14
http://drupal.org/node/1942736 tagged in alpha release
Comment #59
podaroka lot of trailing whitespace errors for #29 http://drupal.org/coding-standards#indenting despite the fact that patch do not applies against latest dev
Comment #60
rooby commentedI'll see if I can dig up the version I was working on in #45 before I hit the road block and compare it to the others we have here.
Comment #61
rooby commentedFound it, but it turns out that it was basically a duplicate of the one in #14.
Silly me for not paying more attention.
Comment #62
rooby commented#25 is not a patch.
#29 needs a re-roll as mentioned by podarok.
In addition to that I had a quick look through and:
Is this related to tokens?
These should be deleted instead of commented out.
This part should not use hard coded field name & langauge.
For reference, you can see how field_tokens uses dynamic language & field names.
Also, there should be more tokens than that.
Comment #63
podarokanyway this is a feature request )
Comment #64
rooby commentedIt is a regression from drupal 6 though.
Comment #65
podarokwoops
Comment #66
sanjay.soni commented#14: token-support-1056154-14.patch queued for re-testing.
Comment #67
podarokLatest one needs work
Comment #68
pfrillingAttached is a patch that I have working for this feature request. I removed the hook_token_list() and hook_token_value() functions and replaced them with hook_token_info() and hook_tokens() functions.
The patch creates a new token for each location field in the database. So if you have more than one location field created, a new token will be generated for each field.
Comment #69
podarokPlease, Upload patch in git diff format http://drupal.org/patch
Not in txt
Comment #70
pfrillingSorry about that. I renamed the file and re-attached.
Comment #71
podarok#70 commited pushed to 7.x-3.x
Patch has a lot of whitespace errors!!!
Comment #72
tvasilia commentedJust a minor question about the last committed patch:
It gives me warnings when importing feeds with location_cck fields... More specifically, I tracked the problem down to this point in code:
According to the API, the $tokens is structured as [machinename] => [type:token]...
However, this code above assumes that $name (i.e. the key of the $tokens array) has the colon character ":" for exploding...
This gives an error because obviously $fields[1] has an undefined index...
Can you please take a look ?
I assume that explode function must be applied to the $original instead of the $name
Thanks for your efforts.
Comment #73
podarok#72 looks like a follow-up bug
Please fill it...
Comment #74
alexweber commentedThe follow-up already exists: #2119967: [Needs steps to reproduce] Notice: Undefined offset: 1 in location_cck_tokens() (line 622 of location_cck.module).