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.
This task issue is for my work on the location_cck module. The patch(es) will probably grow and change depending on reviews and if anything gets committed. But I plan to document all the changes in the patch in the comments for each change.
Comments
Comment #1
dragonwize CreditAttribution: dragonwize commentedCCK calls a load op for each field so it may load its data but since that could result in may queries ran the first load is cached for re-use. Working on location_cck_field()'s load op first eluded me because of that. Only on clear cache would the load op actually be called. Just modifying the $item or $node vars was not enough because the data would only be loaded on first run but not on refresh.
For field data to be cached it has to be returned in a certain format.
Now with this patch, the $node->field_LOCATION_FIELDNAME will be populated with all the location data not just the lid.
Comment #2
bdragon CreditAttribution: bdragon commentedoh, so THAT's the trick? Nice!
Comment #3
bdragon CreditAttribution: bdragon commentedOK, confirmed, that's how to get cck to keep the locations cached. Awesome!
http://drupal.org/cvs?commit=175710
http://drupal.org/cvs?commit=175714
Comment #4
dragonwize CreditAttribution: dragonwize commentedWe can also use the same array to load a copy of the date into $node->locations and $node->location if we want. Like so:
Some conditional would be involved also in case $items is empty but that is the basic idea. That would help provide some backwards compatibility for the location_cck module but I am not sure it needs or should be done. Any thoughts?
Comment #5
bdragon CreditAttribution: bdragon commentedAnd a followup patch: Since the location is being cached, no need to load it before theming.
http://drupal.org/cvs?commit=175718
http://drupal.org/cvs?commit=175720
Thoughts I had while coding:
I noticed location_cck_field_formatter() doesn't seem to get called.
Also, I am also loading the locations for token stuff. I wonder if it's possible to also skip loading it in this case too.
Regarding loading locations and location, that would be nice to have, node locations will have to be copied to a new field (and that considered the new "official" source internally to location) before that's feasible though, otherwise the cck locations would leak into the node locations.
Comment #6
dragonwize CreditAttribution: dragonwize commented@#4
hmm... on second thought that might be more trouble some than it appears. It would work fine for only 1 location_cck field. If the content type had more than one location field it would get really messy. Not sure how that would be best handled but even if we keyed the arrays with field names it would lose the backwards compat which destroys the whole reason for it any way.
Comment #7
dragonwize CreditAttribution: dragonwize commentedHere is the patch I promised a month ago. Back into working on this. This patch puts the location fields into $node->locations like we discussed on IRC.
Next I will be working on the cleaning up more and better views integration.
Comment #8
YesCT CreditAttribution: YesCT commentedtagging. nice to see this!
Comment #9
dragonwize CreditAttribution: dragonwize commentedok, this patch has some fixed views support rolled in as well with the previously uncommitted backward compat support with location_node.
This patch currently supports views relationships which allows pulling each piece of the fields (address, city, country, etc) into your view for display. The ability to filter with that relationship does not yet work though and I haven't tested using arguments yet.
I am continuing to work on the views support. Also I've started to try and get a more organized movement around geo in drupal so drop by #drupal-geo and help hash anything out.
Comment #10
YesCT CreditAttribution: YesCT commented#drupal-geo sounds like a good place to work on a sprint to try and work "real time" on some location issues.
#452806: sprint? can bdragon make it?
Comment #11
dragonwize CreditAttribution: dragonwize commentedWith my testing so far, this patch is working well with the latest HEAD. All views elements are working including filters, exposed filters, and relationships.
Comment #12
dragonwize CreditAttribution: dragonwize commentedForgot the patch :)
Comment #13
KarenS CreditAttribution: KarenS commentedThe 'arguments' and 'views' sections need to be removed altogether. That is the way things worked in D5, those operations are not invoked in D6 and should be removed. I haven't done anything with the rest of the patch, just wanted to note that much.
Comment #14
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedThere are a billion threads on cck location and proximity filter. would this patch help that issue also?
Comment #15
q0rban CreditAttribution: q0rban commentedTried the patch out in #12 and views still don't seem to work. Created a view with a 'Location: Nodes' relationship, and selected 'Content: Address' as the field... nothing displays.
Looking at the query, the join still says: "LEFT JOIN location_instance location_instance ON node.vid = location_instance.vid", which is what landed me at the solution here: #517914: Location CCK Address Fields don't display
Is there a thread somewhere describing why genid is used for location_cck, as referenced here? Is this due to fields in D7 not being node-specific?
Comment #16
dragonwize CreditAttribution: dragonwize commented@q0rban: It works perfectly for me. Ensure that you are setting the "Relationship:" drop-down field in your location field. (see attached screenshot). Your query should look similar to the below.
location_cck works very much like node reference field. CCK stores the lid and that is then related to the correct data by CCK when loading the field.
Patch is rerolled with latest HEAD and Karen's improvement from #13.
Comment #17
q0rban CreditAttribution: q0rban commentedAh, so I shouldn't be using a Location:nodes relationship, but instead just a Location relationship? I'll try that out. Thanks!
Comment #18
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedHas anyone tried this patch which connects the location cck with the node. It allows me to use location without relationship for views
http://drupal.org/node/343943
The posiive is that I can have multiple node types called and their locations without relationships being used. admittedly i have not gotten proximity to work yet.
Comment #19
q0rban CreditAttribution: q0rban commented@dragonwize, I still cannot get this working. Could it be that your patch for location_cck is not up to date with this patch for location.views.inc? I see three relationship options for location. "Location: Users", "Location: Node", & "Location: Node Revisions", whereas your screenshot shows only "Location".
Comment #20
q0rban CreditAttribution: q0rban commented@dragonwize: Ok, so one clarifying question: Your view where it's working is a node based view, not a location based one, right?
Comment #21
q0rban CreditAttribution: q0rban commentedHonestly, I don't see how this can be done with genid. Node based tables need to have joins based on the nid. A snippet from your patch:
Which if I'm understanding correctly is essentially saying join the 'location' table to the 'node' table via $table_alias on lid = $field['field_name'] .'_lid'. Which sounds good, except that location.views.inc already joins to the node table via location_instance on nid/vid.
Also, this means that you can't actually just use the views field that CCK is providing. I have a feeling a custom relationship handler is going to be needed if nid/vid cannot be used for CCK fields in location_instance. The handler would need to parse out the genid from the location_instance table and join location to node that way.
Comment #22
dragonwize CreditAttribution: dragonwize commented@q0rban:
Yes, my patch is only for location_cck on node type views. That is what is taken care of by the cck views calls. Location type views are handled by location.views.inc and were taken care of by another patch of location.views.inc by brandon that I believe has already landed on head. The patch you are referring to is, to my knowledge, attempting to make improvements there.
All your assumptions there are assuming that both peices are working together but they actually are playing separate parts. My patch is only on the location_cck module and use CCk's views support api.
This patch works perfectly for me with location head for back compat with location node and node type views.
Comment #23
q0rban CreditAttribution: q0rban commented@dragonwize,
Thanks for continuing the dialog, its very helpful. I think I'm going to end up switching to location_node instead of using location_cck. I just can't get this working.
Yeah, I understand that location.views.inc is primarily for location views. My point is, look at this code from location.views.inc:
And then compare with your code below in location_cck:
They are both functionally doing the same thing (joining location to the node table). The former one is joining location to node via location_instance, whereas the latter is joining to node via the cck table that contains the location_cck field. In your case it appears that for some reason views is using the location_cck join over location.views.inc's join. In my case, the opposite appears to be true. Either that or my other guess is that it won't use the cck table to join because the cck table is already joined to node for the other cck fields.
Anyways, thanks for your help, I hope you're not feeling like I don't appreciate the time you've put into this!
Comment #24
dragonwize CreditAttribution: dragonwize commentedAgain you are assuming that both code is running at the same time, they don't, or at least shouldn't. When you are building a location type view you use join relations to nodes, that relation is set in location.views.inc and is ran when a node relation in a location type view is setup. When you build a node type view and you relation to a location cck field, that relation is set in location_cck via the cck api.
I do not know what modifications you have made from head but it sounds like you have made a few. Try the patch with a clean version of head with this patch.
I do not want to drive you away, if there are issues with this patch I want to find and fix them, but to do that we need to be able to synchronize what we are doing to find out where the issue is, as there are just too many variables in play right now. Any information about your setup and your view, even a copy of a view export may be helpful.
Comment #25
rucx CreditAttribution: rucx commentedi've noticed a bug with your patch in 2 installs of mine, please try and see if you get the same result:
- just change default location in location - main settings to any other country of your choice (or in cck same thing)
- now go to add node ... did the default country change or is it still the same? in both my installs the default country configuration wont change anything since i applied this patch.
Comment #26
rucx CreditAttribution: rucx commentedfunny, my default country of choice is set right in edit node if i create a node with empty location, but at add/create node the default country wont change to my configuration choice.
Comment #27
rucx CreditAttribution: rucx commentedlol, solved the problem by deleting cck location field and creating a new one. seems like you cant change default country once the cck field has been created.
Comment #28
dragonwize CreditAttribution: dragonwize commented@rucx:
What you are experiencing is a usability issue outside with location_cck outside of this patch. I've talked with Brandon about this a couple times but we have not come up with a good solution yet.
The issue is that there are 3 different places that are labeled for default country but each one actually has a specific place it sets the default. The default country under the admin/settings/location area is to set the default country when creating new content types for location_node. The CCK default values fieldset only sets the default country for the first field of a cck field. The default country in the location fieldset of the cck field actually sets the default country for the fields after the first of a multi value field.
We are working on that issue but currently it is part technical and usable issues that we are trying to match up to work well.
Comment #29
roball CreditAttribution: roball commentedThank you for the patch #16. Works perfectly for me! Should be committed.
Comment #30
roball CreditAttribution: roball commentedThe patch from #16 was against HEAD version 1.16 of "location_cck.module". Meanwhile, we are at v. 1.23, and it does not seem that the view improvements from this thread have been implemented. So, do we still have to apply the patch - and will it work - or must the patch be updated?
Comment #31
dragonwize CreditAttribution: dragonwize commentedPatch re-rolled with latest HEAD.
Comment #32
roball CreditAttribution: roball commentedThank you - patch #31 works perfectly for location fields in views with Location v6.x-3.x-dev (2009-Jul-31). I am using it at https://www.iseki-food.net/drupal/upcoming_ifa_events_all.
Comment #33
bomarmonk CreditAttribution: bomarmonk commentedAfter applying this patch I get the following error: "warning: include_once(./sites/all/modules/location/contrib/location_cck/location_cck.module) [function.include-once]: failed to open stream: Permission denied in C:\xampp\htdocs\mysite.com\includes\bootstrap.inc on line 611."
I'm not sure if this is because of my setup with XAMPP, but the module worked fine before the patch. I've checked that the file permissions are not read-only.
Comment #34
dragonwize CreditAttribution: dragonwize commented@bomarmonk: I appreciate you testing this patch. However, a patch itself does not affect a files permissions. So while I hope you find the issue, it is not this or any patch. You should check your file system again.
Comment #35
bomarmonk CreditAttribution: bomarmonk commentedYes: I fixed this by following the instructions here: http://drupal.org/node/248176#comment-1001200. I'll let you know how the testing goes. Sorry for the unrelated issue: I just wasn't sure.
Comment #36
bomarmonk CreditAttribution: bomarmonk commentedAll right, hopefully this is related to this patch. I didn't get this warning until after the patch: "warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\mysite.com\sites\all\modules\cck\includes\content.token.inc on line 59." This warning appears when editing my content type that includes my cck location field. It quickly disappeared after refreshing the page, but now, under "manage fields," my previously created CCk location field is reported as disabled: "This content type has inactive fields. Inactive fields are not included in lists of available fields until their modules are enabled...Location (field_location_cck_reusable2) is an inactive Location field that uses a Location Field widget." Is there no upgrade path for prior fields?
Comment #37
yrre7 CreditAttribution: yrre7 commentedsubscribe
Comment #38
yrre7 CreditAttribution: yrre7 commentedThe patch #31 doesn't seem to work with proximity search. If you input a number in the "miles" field, it will always display empty. If the "miles" field is empty with the correct zipcode, then it's able to produce the result. Any idea why it's like this?
Comment #39
fred0 CreditAttribution: fred0 commentedHmm... I've been digging around in the voluminous list of issues here and this is the closest to my problem that I've found. And since this seems to be the most active work on location_cck, it seems like the place to post. The patch in #31 works against the July 31 dev and certainly does seem to make improvements. The cck data is related properly and one can use the Location fields to display the various data. However, what doesn't seem to work is using the actual cck field itself. It appears in the Fields>Content list as an available cck data field, but when you add it to the display, it returns empty. The format pop-up is presented and provides the same options as the cck Display Fields setting (Address, Address with Map, Map only, Multiple field values on a single map) but none of those choice seem to matter.
I, in particular, would like to display the Address with map option in my view.
Anyone have any ideas?
And while I'm at it, the token support seems to have an issue with modules like auto_nodetitle and pathauto. The token isn't passed on the initial node save and the auto_nodetitle gets set to the token reference (ie - [field_location_name]) instead of the value of the field. Editing and re-saving the node then results in the proper behavior and the node is named.
Comment #40
fred0 CreditAttribution: fred0 commentedThe first half of my last comment was not very clear. I've now found an issue that is a bit more specific and done a better job explaining the bug here: http://drupal.org/node/427432#comment-2072838
Comment #41
cdale CreditAttribution: cdale commented@fred0 - I believe I provided a possible solution to the first part of your issue at http://drupal.org/node/427432#comment-2251824 (#14)
The second part, regarding the token support, is actually an auto_nodetitle bug, and can be fixed by applying the patch from http://drupal.org/node/194197#comment-2202358 (#69)
Comment #42
nickl CreditAttribution: nickl commentedI was just about to call this patch rtbc but then I rolled back to DRUPAL-6--3 to create another patch quick. I must admit that it took some serious configuring to get a node based view to work with the Location relationship and configuring every location_cck field for testing. You can imagine my shock when after removing the patch only to find that the view is still working. Filters, exposed filters, arguments, sort criteria, all the styles, grouping by location field the whole shebang, everything I've just tested works the same with the patch as without.
The idea for this issue, correct me if I'm wrong, is to create backward compatibility with location_node. Which it is failing to do completely, by using a relationship to expose the cck location data to views, rendering the view incompatible with node location data. What is the point then, we will be better of going the location_instance route which can indeed have these two misfits behave each other in one view. See #391160: CCK/Views: location_instance fix Did I mention easy as pie to configure?
For the second part of the patch, I fail to see what the benefit is to populating $node->location and $node-locations. If these do somehow make our lives easier and the code base simpler and more stable or even just one of the above then I will agree, lets go ahead and commit, until then I'm marking this issue "needs work".
Instead of making things more complicated, lets work together to fix all these outstanding bugs, get the issue queue cleaned out, write some documentation, get more maintainers involved and lets turn this very special project into something extraordinary.
Back to the topic: How can we get these two very similar modules to stop stepping on each others toes and work together? Do we even need to concern ourselves with compatibility? Why are we keeping both? What are the pros and cons? Lets talk about it again and again until we find a practical solution...
KISS
Comment #43
thill_ CreditAttribution: thill_ commentedsubscribe
Comment #44
roball CreditAttribution: roball commented@nickl: confirmed - the patch is no longer required for Location 6.x-3.x-dev (2009-Dec-17) used with Views 6.x-2.8 :-)
Comment #45
piepkrak CreditAttribution: piepkrak commentedsubscribing