Closed (fixed)
Project:
Addresses
Version:
6.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 May 2009 at 14:17 UTC
Updated:
3 Jan 2014 at 00:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dooug commentedI second this request. I spent a while today digging through the Addresses module's code and trying to improve the token integration for more than just the field display. For example, I tried to work with the Addresses tokens in the PathAuto and Auto_NodeTitles modules but the tokens just don't show up. It seems that the addresses_token_list and addresses_token_values hooks either aren't being invoked or aren't returning anything.
I couldn't spend any more time on this and had to find a different solution for what I was doing. However, I am still interested in seeing this improved.
Comment #2
davidneedhamI agree, this should be implemented.
Comment #3
drecute commentedI completely agree to this feature request.
Comment #4
AlexisWilke commentedI looked at the code and did not see any reason for it not to work... for addresses!
I will test a few things, but it looks to me that the $object can only be an address at this point. I think we would need to support a $user and a $node to complement the use of tokens on user paths and node paths. (the node would make use of the CCK and I'm not too sure how that works if you have an array of CCK fields...)
Thank you.
Alexis
Comment #5
alexd73 commentedHi!
I have a CCK-field field_address, which contains a Normal or Required fields: Country, City, Street, etc...
I want add a token (such as [field_address_city]) in Automatic title generation. How I can do it?
Comment #6
AlexisWilke commentedalexd73,
First of all, if one of the address fields is required in a CCK field address, then all the fields are made required. This is a side effect of using CCK.
I think, from what I understand, that other users have problems with CCK tokens. I did not see any problems, but I'd need to test and see what's happening.
Thank you.
Alexis
Comment #7
alexd73 commentedAt you is normal? What token I should write?
Comment #8
dkinzer commentedI'm working on fixing this for CCK so I'm sure it will fix it for Patterns and other types that rely on token lists with type 'node'
Comment #9
dkinzer commentedHere's the patch I promised in comment #8
Currently the addresses module contributes token values only with objects of type
'addresses_general', or 'addresses_adr'
But a lot of contributed modules that support tokens features (Such as the Rules module) expect the object to be of type 'node', or 'user' etc. So that's part of the problem.
The fix for CCK was looking at the following snippet from the content.token.inc:
The important bit here is
$function = $field_types[$field['type']]['module'] . '_token_values';.This shows that the content module is looking for a function called
addresses_cck_token_values()(there is an equivalent function for the list).Attached is a patch where these missing functions are added to the addresses_cck module.
It fixes the issue as long as you are using the CCK address fields.
Enjoy,
D
UPDATE: The patch Below has a dsm()... I forgot to remove. I've created a new patch which I will upload shorly
Comment #10
dkinzer commentedThis is the fixed patch from #8
Comment #11
AlexisWilke commenteddkinzer,
That would make sense! 8-)
I'll wait a bit to have others test your patch in #9 and if it works for them I'll check it in.
Thank you for sharing!
Alexis
Comment #12
dkinzer commentedGreat! ... Note that the patch on #9 has a rough dsm() call that I forgot to remove. I corrected and reattached the patch in #10.
Comment #13
realityloop commentedThis appears to currently be returning a definition list for each value, to match other returned token values it should probably only return the value itself.
I don't think it should return HTML code as not everyone will be using HTML email.
Comment #14
AlexisWilke commentedrealityloop,
Are you saying that the patch transforms things in a way that prevents plain text emails?
I thought we could use the tabs and depending on the type adjust the output. I suppose that the Addresses code should test that type and adjust the content accordingly. But I'm not a master at CCK...
Thank you.
Alexis Wilke
Comment #15
dkinzer commentedIt is not the case that these fields are not accessible as plain text.
In fact there was no way of accessing the individual fields without going through the Addresses module's theme function (it has nothing to do with how CCK asks for tokens). However, as shown below all the token fields are indeed returned in plain format as well as hcard format. In fact I used the plain formatted output to generate a non HTML email.
CCK addresses tokens
[node:field_ask_address-is_primary_plain] "False" if the checkbox is not checked, otherwise "True".
[node:field_ask_address-is_primary_hcard] An hcard/vcard html representation of the primary checkbox.
Comment #16
realityloop commentedAlexis: no, but when using htmlmail module the fields are returned as dt & dd which is not consistently controllable with the limited CSS that HTML emails allows.
Dkinzer: I'm using the _plain variant for all of my fields but the output in the received email has the dt & dt tags around field title and field value.
Comment #17
butler360 commentedThe patch works, but some tokens seem odd to me. Like First Name and Last Name show both the label and the value. Will additional tokens be added to we can just use the values?
Comment #18
dkinzer commented@butler360, either the Addresses module has to be modified so that it doesn't force us to go through it's theme functions in order to retrieve these fields, or we need to add a 'cck' type theme format to the Address module that returns a true simple, plain field value [which really should happen when one asks for the plain format].
The latter is the easiest solution. So I'll do that and post the new patch when I get a chance.
Comment #19
butler360 commentedI agree about the "plain" stuff, and thanks!
Comment #20
dkinzer commentedOK so there was an extraneous
foreachstatement that was erasing the plain format output. I've removed it and attached the new patch.Comment #21
dkinzer commentedOops, that patch on #20 is unnecessarily cluttered. :) I'm resubmitting it here
Comment #22
dkinzer commentedUgh, that was the wrong patch, sorry. Here it is again.
Comment #23
realityloop commentedThis works well, can we get a plain version of the Business field as well though?
Comment #24
dkinzer commentedrealityloop, what's the business field? I'm looking in the addresses module and it's not defined. Perhaps it's being defined by another module, like the phone field is?
Comment #25
AlexisWilke commentedAh! Good catch. The business field is part of the Addresses Extras module.
Comment #26
realityloop commentedAh, my bad.. then I'd say it's safe to mark #22 as RTBC.
AlexisWilke: I had a look at the source for Addresses Extras but couldn't figure out how to add plain versions there, would be nice to see this included in it if possible? I've created an issue for it http://drupal.org/node/972718
Comment #27
AlexisWilke commentedOkay, #22 is checked in the 1.x-dev version. Thank you!
Alexis
Comment #28
dkinzer commentedcool. Thanks.