Hello everyone, this is my first issue. I have been googling all day and I can't find an answer.
I have users with a profile2 called "Business". In the profile2>Business profile, I have a location field(field_location). Now when I create a view, I just want to show the label and town. Unfortunately, the only options I have are "Location: *all options for users*" and "Profile:Location". Choosing the latter displays all fields (address, label, town, etc..).
I've tried creating the view with Profile>(type)Business, and User with a relationship of Profile. When the view is created with User, the Location:label doesn't allow to choose the relationship I created with Profile.
Is this a bug, or something that hasn't been implemented yet? I could settle with user locations, but it would be WAY better to use Profile2 instead (for my particular application). I apologize if this is a duplicate issue, as I'm sure I'm not the only one who had this issue.
P.S. I've used both 7.x-3.x-dev and 7.x-1.0-beta1
Thank you,
Brett
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | location-profile2-views-gmap-formatter-1647734-8.patch | 3.09 KB | raulmuroc |
| #4 | location-profile2-views-gmap-formatter-1647734-4.patch | 3.1 KB | mjs2020 |
Comments
Comment #1
d.vandoninck commentedI'm curious about this as well. When I make a new view for users, I can create a relationship between user and profile. Though the location fields that I can add are linked to the user, while I need the location fields from the profile instead as they are two different entities. The only solution I've found so far is to make a location field for the user and then hide it. You can then add fields for street, city, country, etc on the profile and with a custom submit handler, update the hidden location field. This would allow you to use the location fields in a view.
Comment #2
smithwib commentedI've got the same situation. Profile2 has a location field, but it is not visible in a view -- I've tried basing the view on User, Profile and Location, but I don't have the ability to choose the appropriate Relationship. Not sure if this is a problem with Location, Profile2 or Views.
Comment #3
anthem0n commentedHi all,
Same problem, any help or update ?
Thanks in advance,
Comment #4
mjs2020 commentedHi,
I made a custom formatter called "Individual field". Basically in a view you need to have the relationship to the profile and then you can add your location_cck field ("Business" in bporter2387's case) and under "Formatter" you can select which individual part of the address to show:
Image: http://s15.postimg.org/qd5nq1wwr/Screenshot_location_formatter.png
Your options are: name, street, additional, city, province, postal code, country, longitude or latitude.
This was particularly useful in my case to output longitude and latitude for an extended gmap view. The extended gmap can use as data source the location module but it won't work with fields attached to profile2. By outputting longitude and latitude with the new formatter you can use "latitude and longitude fields" as data source:
Image: http://s13.postimg.org/68ejefdzb/Screenshot_data_source.png
and then just exclude them from display so they don't show in the bubble.
The patch below is against the current dev version.
This is my first patch, I tried to follow guidelines but if you see problems feel free to point them out.
Comment #5
hanskuiters commented@mjs2020: YOU ROCK! Thank you.
Would be cool to also have the single fields to use for filters.
Comment #6
podarokhttps://drupal.org/coding-standards#indenting
indenting errors shoud be fixed before RTBC
Comment #7
jbizzay commentedYeah this saved me a lot of work, thank you. By the way, this patch depends on the gmap module. I'm not using that module, but had to download and enable it just to use this patch.
Next I have to tackle setting up these fields with filters :|
Comment #8
raulmuroc commentedWithout withespaces. should be RTBC.
Comment #10
raulmuroc commentedThis patch doesn't work for me completely.
How to reproduce
Just follow the steps stated above by the owner of the patch.
Following errors raise up
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 173 of includes/entity.inc
Notice: Undefined property: stdClass::$location in location_views_proximity_get_reference_location() (line 592location.views.inc
-----
And the curious is that just for ADMIN USER is shown the map. For the others not.
Comment #11
raulmuroc commentedTo try to reproduce better.
Now i changed in ADMIN my location info. The map worked like a charm :D
Then I logged and changed in another users: basic, premium, authenticated... and there appears those errors explained in the post before.
Thank you.
Comment #12
haggins commentedSame problem here: Want to filter profiles by proximity which only works if I add the uid manualy to the {location_instance} table. Would be perfect if we were able to select a profile relation in the handler settings.
Comment #13
raulmuroc commentedComment #14
Christophe Bourgois commentedI am using location 7.x-3.7, so the #4 patch is working for me, but doing the changes in the file manually.
After applying this patch I can choose individual field, and then select the field I want to show.
The result is that it is showing the desired field, this point is ok.
But I have a question, how to select this field in an exposed filter criteria, as source of autocomplete field.
This is not working for me.