Posted by chill8331 on May 8, 2009 at 10:30am
Hi folks,
Gmap + Location + views
How to reference locations (considering maybe a select box) to node? Which means when you create node just select a location to associate.
I was trying this with User reference with views. But it gives me only one result. Here's the situation:
If i limit the user in the views filter like 'Current user', The result will be only one location from the user. why does that?
If i don't limit user in the views filter it just give me all user's location in the website(but still only one per user)?
Is there any limits on User reference or i miss something?
Anybody can help or have other solutions?
Thanks!
Comments
Configure locations in the content type
To do what you want, configure the content type to accept location(s).
It's a little confusing, because the form appears below the "Submit" button. That's a graphical bug in the module. But it does work.
Good luck,
Tom Geller * San Francisco
Author/Presenter, "Drupal Essential Training" video series at Lynda.com
TomGeller.com * GellerGuides.com * SaveMyHomeBook.com
Tom Geller * Oberlin * San Francisco * TomGeller.com
Author/Presenter, Drupal video series at lynda.com
Creator of materials for Drupal-focused companies
Thanks for your reply
Hi Tom
Thanks for your reply. Let me explain something and clarify the requirements first.
I know that in content type can add location. but i don't want to add location for each node. What i was trying to do is the user's locations are added in when they registered and might be limited(let's say 3 locations). Later on when user post node i can associated the node with a specific location in 3 locations from their profile. And then might be need to render the coordinates in the Gmap(Views or whatever way). But it looks User reference is not gonna work for the reason that i already described.
Am i make it more understandable? And any suggestions? I already start thinking to alter the node edit form and make another table in the database.....
Thanks again!
A-ha! Now I understand. Use relationships
Hi, Chill. I think I understand the problem now... and might have a solution. (I haven't tested it, but it works in theory :) .)
What you need is a relationship. See, when you do a node or user reference, all you get is the node/user title exposed in Views. To access all the other fields -- including the location -- you need to set up a Relationship in Views.
Conceptually, this is one of the most difficult subjects in Drupal administration. The good news: Matt Petrowsky covers it in a 21-minute video on GotDrupal.com. (I also cover it in my new Lynda.com series, but that won't be out for a few months.)
I hope that solves your problem! Let us know if it doesn't. Cheers,
Tom Geller * San Francisco
Author/Presenter, "Drupal Essential Training" video series at Lynda.com
TomGeller.com * GellerGuides.com * SaveMyHomeBook.com
Tom Geller * Oberlin * San Francisco * TomGeller.com
Author/Presenter, Drupal video series at lynda.com
Creator of materials for Drupal-focused companies
Sorry, I didn't make it.
I was try to implement this in views but it's not working.
Let me explain the theory.
Add a field use User reference in product. and retrieve whatever uid or user name. that is a user views.(field_user_location)
Normally we have to get another node views related to this user views, right? But what i want to render is Locations. I also tried in this way and can see the field_user_location in the relationships. But i can't get any result's from this views and it looks don't have any relationship at all. (I figured it make sense, because this is node view. what i want is locations)
Now i tried to set up a location type views to attach the relationship with field_user_location. But i can't select this item in the relationships. That's weird! It should be some relationships between locations and users, no?
Anyway, i give up with this. I'll make this by hand:). I can't spend too much time to do research. But If anybody can figure this out i also glad to know.
I appreciate for your patient to answer my questions one by one, Tom. Thanks again.
I'm afraid I'm out of ideas
Hi again, chill8331. I'm afraid I can't think of other solutions. Perhaps if you say exactly what you're trying to do, we can think of another way to architect it. (I mean, give the specifics: Are these three locations where the person lives/works/travels? Why do you need to choose from among them?) Sometimes the best way through a barrier is to go around it. :)
Cheers,
Tom Geller * San Francisco
Author/Presenter, "Drupal Essential Training" video series at Lynda.com
TomGeller.com * GellerGuides.com * SaveMyHomeBook.com
Tom Geller * Oberlin * San Francisco * TomGeller.com
Author/Presenter, Drupal video series at lynda.com
Creator of materials for Drupal-focused companies