Right now you can't use any of the default views2 support for location data stored in CCK location fields because there is no join between the content field table and {location}. The attached patch adds a relation that is patterned off of the Node and User Reference modules.

Comments

drewish’s picture

StatusFileSize
new2 KB

whoops, last patch had some unrelated changes.

bdragon’s picture

+1, I kept wanting to put this in but kept getting lost when trying.

drewish’s picture

Title: location_cck's a views relation » location_cck needs a views relation

better title.

yesct’s picture

I'll try this patch. Thanks!

bdragon’s picture

Aaaand, I feel stupid.

I went and independently reimplemented the relation yesterday, after having forgot about this patch.

drewish’s picture

high five! i've totally done that to people in my queues. now i'll just go ruthlessly review your code and post a correction patch ;)

bdragon’s picture

Sounds good to me :)

scottrigby’s picture

Hi, I tried to do this with the current dev version, but wasn't able to. (adding a relationship -Configure Relationship Content: Location [field_name])

Then I looked to find bdragon's implementation, but wasn't able to understand how this worked for individual Location fields.

However, when I applied the patch in #1 by drewish (had to apply by hand because of changes since in dev), I was able to retrieve individual Location fields in Views.

So the patch seems to work for me... But am I understanding this correctly?

drewish’s picture

scottrigby, yeah bdragon didn't apply my patch and did his changes independently. could you roll a patch from the changes you applied?

scottrigby’s picture

StatusFileSize
new2.63 KB

Hi Drewish - yup - here's a patch against the latest.
But... I'm not sure what bdragon did independently on this issue, so this doesn't account for any possible conflicts with the independent changes he did -- I haven't run into a problem yet, but if you have a better sense of those changes could you see if this could be an issue? Maybe it's not, which would be great :)

bdragon’s picture

Assigned: Unassigned » bdragon
Priority: Normal » Critical

Bumping this up and having another look.

monjohn’s picture

This patch wouldn't apply to the latest release. I tried to apply by hand but still can't get the functionality. I thought that I had it before I updated the module though.

yesct’s picture

Anyone have a patch that applies now?

yesct’s picture

Anonymous’s picture

Status: Needs review » Needs work

Successfully applied patch from #10 above, but cannot see any changes to relationships in views... Am I missing something?

yesct’s picture

Tagging.

yesct’s picture

yesct’s picture

yesct’s picture

alternate method #431290: Views -> Field Location: Coordinates = NULL (please take a look and discuss)

bdragon’s picture

StatusFileSize
new3.19 KB

OK, patch reroll with just the good stuff and a way to disable the implicit stuff with a variable change / cache clear.

yesct’s picture

StatusFileSize
new3.2 KB

small change to the patch to fix the default labels for nodes and node revision relations

here is a diff on my patch vs bdragon's latest

diff location.*
24c24
< +      'label' => t('Location: Nodes'), // @@@ Some sort of better name?
---
> +      'label' => t('Location: User'), // @@@ Some sort of better name?
47c47
< +      'label' => t('Location: Node revisions'), // @@@ Some sort of better name?
---
> +      'label' => t('Location: User'), // @@@ Some sort of better name?
Anonymous’s picture

Just applied YesCT's patch from #21 to latest location.dev (April 18). I created a new View of type 'Term', but in Relationships, the only option is 'Taxonomy: Parent Term'...

Someone able to explain how this works?

yesct’s picture

Hmm, I think the only views I have tried are of type "node".

libeco’s picture

Sorry if I did not understand this properly.

I'm using this on a local test setup:
Drupal 6.11
Location 6.x-3.x-dev (2009-Apr-18)
Gmap 6.x-1.x-dev (2009-Apr-18)
CCk 6.x-2.2
Views 6.x-2.5

Using the dev versions was the only way for me to let a map show up in the location block in Drupal 6.11.

I just used the patch in #20 (copied and recplaced in original file). I created a location view and used Location: Nodes as relationship.

But what's next, where can I use this relationship?

I'm trying to create a proximity search view (aren't we all when searching for this here on Drupal :)).

Thanks in advance!

jasontanner’s picture

.

Anonymous’s picture

#23

Uh, yeah. I must be losing my mind... I'm looking for a relationship from a term to a node. Don't know why I'm here...
Keep up the good work guys :)

bstankie’s picture

Hello-
I've applied the original patch, patch #1 and patch on cck. I now have a relationship ('Location:Noes') but I still cannot get the location information to display in the Views. Perhaps there is a step that I am missing. Can anyone summarize the steps that they have used to get the location module to work with Views.

I am willing to help however I can.

Thanks,
BStankie

vm’s picture

the patch is #1 is no longer relevent you want the patch in #21. Always use the last available patch rather than the first.

vm’s picture

my testing of this has found no bugs. I hesitate to move to needs review until others have also tested.

RoboPhred’s picture

The patch in #21 no longer applies against HEAD.

vm’s picture

It applied to -dev for me. I didn't try HEAD

yesct’s picture

I was making a video of doing some location stuff, and while trying to apply this patch, I had to disable views and views UI, then re-enable them, for it to see the changes made by the patch. Is there an easier way to get it to see the changes make to the code? (cache clear did not seem to do it.)

yesct’s picture

I made a video trying to see what this patch is for.
http://cathytheys.blip.tv/file/2157286
More coming, more questions and more demos.
But I got some stuff to work without the patch.

mdayton’s picture

subscribing

mrgoltra’s picture

tag

rangerfrex’s picture

Thanks, subscribing

BaronVonInternet’s picture

I know next to nothing about how Location/Views/CCK work and relate to one another, but I can say that I applied the patch in this thread to the latest dev version, and it patched properly but didn't seem to do anything at all, even after disabling and re-enabling views+views ui+location as suggested.

However, for anyone who needs an immediate solution without modifying any core files (or any files whatsover, not even patching) here is a quick (and perfectly safe?) way to make this work until a true fix is released.

In the database table location_instance, you will see that vid for these fields is always "0". You will also see that the genid fields are something like "cck:field_location:35". If you manually put that last id number into vid for each record, it starts working. From there, you could set up a hook or cron to run a script to fill in those fields automatically (sorry, in my case I just needed to use it with some prepopulated fields so I haven't done anything like that).

Edit: Duh. Or you could just use the relationships method described by YesCT in her video. I missed that the first time around, and that's definitely simpler than having a hook to run an update on that table.

kmonty’s picture

Subscribe

izmeez’s picture

subscribe

socialnicheguru’s picture

YesCT #33 thanks for your videos.

I guess my question is why do I need this patch? Everything seems to work when your cck value is a relationship. I only have a single location per node. I don't know how this works for multiple locations per node.

Would any of these patches help me with proximity search for location cck fields?

Thanks,
Chris

Webster619’s picture

This patch is needed if some has a series of state nodes and business nodes. Each business node is associated to a state via location module. With this functionality you can now create a single view that will display the business nodes in a given state on each state node.

jthaxton’s picture

I have applied the patch, but my CCK location nodes never show up in the relationships list. I feel I am missing a very basic step in setting things up.

sagannotcarl’s picture

YesCT, thanks for the video. I got everything working up to that point but it's still pretty limiting to have to type in static lat / long. Is a separate relationship needed to key that filter off the current node (for example)?

pursuitofliberty’s picture

subscribing.. also having same issues with recent dev build

zmove’s picture

Hi,

I followed the video, putting the relationship between the location node and the CCK field.

My field appear in a view when I go to the field options, and that I select the relationship.

However, I need to filter views depending on a country, I did the same thing for the country filter : Location > country, I put the relation on that filter, I expose it, and when I try to use it, I always get no results : this is exactly the same behavior than before the relationship.

So this solution seems to work to display field, but not to filter them.

Any ideas ?

nickl’s picture

Status: Needs work » Closed (duplicate)

This approach is not ideal, working patch ready to be revied which solves this issue as well CCK/Views: location_instance fix

kpojeta’s picture

subscribe