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.
The CCK address field seems to be ignored or not working correctly in our test environnement when used in views filters/exposed filters. The field Address appears in our filter criteria, but it seems to not work correctly.
Two examples:
1) Predefined filter: our City field value in a record is Toto. If the filter is "Address Contains Toto", the view still displays all other records.
2) Exposed filters: the same test gives an empty result set, no record with City=Toto displayed when typing Toto in the exposed filter (for any filter type: Contains, Contains all words, Equal, etc.)
Thanks
Comment | File | Size | Author |
---|---|---|---|
#15 | cck_address_search.patch | 3.17 KB | Anonymous (not verified) |
#9 | cck_address_views_204660.patch | 8.65 KB | deviantintegral |
Comments
Comment #1
rconstantine CreditAttribution: rconstantine commentedThat's funny. I thought I had an issue for this already. Turns out this has only really come up in regards to my cck_fullname module, but the issue is the same - i.e. I haven't had much time to try and figure out Views integration and so I just sort of threw something together. So I'm not surprised that it isn't entirely working. With that said, I don't really have time in the next several weeks to get to something like this. If you know how to code and can fix it, that would be great.
It may be that CCK itself is to blame for the wrong-ness of how my module is interacting with Views. For some reason (and this still has not been addressed by the CCK team) CCK modules are expected to have a single value and not be compound values like addresses are. In other words, CCK only recognizes the first column stored as a valid (sortable) value. This caused me to reorder the columns in my cck_fullname module so that last name was first - which would produce more natural alphabetizing results than sorting by first name!
Anyway, my lame answer for now is that I'm not sure whether modules such as mine can work properly at all with Views so long as CCK itself is the way it is - assuming I'm right about how CCK is. If someone out there that knows the Views code and/or CCK code better than I do has any answers for this module, I'm all ears.
Comment #2
ardelio CreditAttribution: ardelio commentedA few additional details:
- I can confirm that the filter Address takes into account the first line of the Address field only (the street part).
- The behaviour is wierd even for that part. If the address is "12, domine", the filter "Contains" will find the result for the query "12", but not for "domine", while "Domine" will work; for another address the query is not case-sensitive and works correctly in both cases.
Thanks
Comment #3
rconstantine CreditAttribution: rconstantine commentedMaybe you could get someone at CCK to look at this issue and help us out. That would be nice.
If there was an obvious choice for a field to sort on, I could re-order the columns like I did for cck_fullname, but I could see that people would complain no matter what I chose. On the one hand, international sites would want to sort by country, U.S. users possibly by State, local/regional users by city or ZIP, and focused sites by street. So until CCK is fixed, I fear we can't do anything about it. :-((
Comment #4
MacRonin CreditAttribution: MacRonin commentedDang ... I was hoping to be able to create a sort/selection in VIEWs based on state then city. I guess I might have to go back to separate fields for the diff parts of the address.
But then again maybe I'm lucky and there has been some activity on this front that I missed. Fingers are crossed.
Comment #5
MacRonin CreditAttribution: MacRonin commentedDang ... I was hoping to be able to create a sort/selection in VIEWs based on state then city. I guess I might have to go back to separate fields for the diff parts of the address.
But then again maybe I'm lucky and there has been some activity on this front that I missed. Fingers are crossed.
Comment #6
rconstantine CreditAttribution: rconstantine commentedNo luck. I've been swamped and haven't even tried to understand what needs fixing in CCK to get such things as this to work. IIRC, there is an issue in CCK's queue regarding Views and CCK fields with multiple sub-fields, but I haven't seen any activity on that either. This is a big PITA, isn't it? If enough people would get on CCK's case, this could get fixed.
Comment #7
jason.fisher CreditAttribution: jason.fisher commentedThis is not an endgame-solution, but possibly viable for someone looking to solve a specific problem in a very specific situation.
I have one CCK Address field called field_address that is shared by multiple content types, thus it has its own "content_field_address" table. I have hard-coded this to offer that table up to Views using the define() below.
For my use, I have placed this code in modules/cck_address/views_cck_address.inc:
and then, somewhere in the top of cck_address.module:
After clearing the views cache, I now have CCK Address fields split out for use in the "Table", "List" or "CSV Export" (bonus pack) types -- it should also be sortable, but have not tested.
You can use City/State/Zip as filters and expose them. Arguments are not implemented here, but should be trivial to support.
--
I will not be updating, maintaining or submitting a patch for this -- if someone can make the code a bit more intelligent (i.e., have it find the proper cck_address field automatically), it could be useful to the public.
Thanks,
Jason
Comment #8
rconstantine CreditAttribution: rconstantine commentedComment #9
deviantintegral CreditAttribution: deviantintegral commentedHere's an updated version of the above which works with (some) arguments. Currently, city, state, and an abbreviated state work.
Thanks!
--Andrew
Comment #10
ekrispin CreditAttribution: ekrispin commentedIt does not work in my case (I tried the last patch). Tried to add exposed filters of Address: State and Address: City and it doesn't find anything.
Maybe the issue for the bug is that in my case there are 2 different fields of the type Address in the underlying content type?!?
Comment #11
As If CreditAttribution: As If commentedAfter applying the patch, make sure you empty the 'cache_views' table. (And thanks, you guys!)
NOTE: As implied by the comment above, this patch *does* require that your field name is standard, ie: 'field_address' not 'field_location' or anything else.
Comment #12
deviantintegral CreditAttribution: deviantintegral commentedYes - I have it as a define() so you can change it, but hopefully someone who knows more about CCK knows of a better (dynamic) way to do it.
Comment #13
awolfey CreditAttribution: awolfey commentedI needed an argument by the starting state letters, so I copied this from taxonomy and modified it:
And then the function. I probably don't need everything in there but left it in anyway:
What I couldn't figure out how to adapt is the group-by sort for sorting by state abbreviation. I would appreciate any help on that.
Here's the page:
http://sineny.bigcitydev.com/store-locator
The address field is also printing the blank address lines, but that's another issue.
Thanks,
Aaron
Comment #14
zkrebs CreditAttribution: zkrebs commentedI need to create a list of businesses (content type) that is filterable by City. Right now, there is no obvious way to do this. Is there any recommended configuration of Drupal / Views / Address Field CCK / CCK that will help me achieve this result? I need an easy to understand solution that will upgrade. I am willing to test anything someone produces.
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedI have implemented a quick patch to allow a subset of searching to work on address fields. In my case, I would search the address field for "Michigan" using the exposed filter and get no results returned, even though nodes had Michigan for the state. The attached patch creates a views handler for the 'like' operator and allows you to search multiple fields. Currently, the fields that are searched are controlled by the function cck_address_components(). This is obviously not ideal and should be pushed into a UI config option. Unfortunately, I don't have time to do that work now, so I'm giving what I have to the community.