I have location CCK and I can't filter this field in Views.
Are they compatible?

I've looked at #391160: CCK/Views: location_instance fix but it applies to D6.
also I've seen #1064666: Location CCK not saving for entities other than nodes but not sure if it's related

Comments

ankur’s picture

Status: Active » Closed (fixed)

You can filter the locations as node locations. CCK locations are saved to the same table and are queried the same way. The ability to create a location relationship to the CCK location field and then filter on fields using the relationship doesn't exist in 7.x-3.x. Both work, but the drawback with not having the CCK location limitation is that if you have more than one location CCK field, but only want to filter on one of them, you will need the relationship.

mstrelan’s picture

Status: Closed (fixed) » Active

How is this "fixed"?

If you have more than one location CCK field, but only want to filter on one of them, you will need the relationship.

It is absolutely essential for my project to only show one location field, as I have physical address and billing address. It makes absolutely no sense to show billing address on the map.

Nchase’s picture

Having nodes with more than one location field creates duplicate entries in views, as much as location fields are in the node.

I haven't seen any relationship in views that let me select the field.

glynster’s picture

I am currently dealing with the same issue. However I have a User Field for the location and a view created in the hope that I can expose the city and country filters. However I am not getting any results due to not being able to set a relationship.

Has anyone figured out a way?

ydahi’s picture

Same issue as glynster.

Add CCK location field for user account.

Create a view that lists users.

Add location fields in view (i.e Location: City) - field is empty.

However, same process for nodes does render the field properly.

Can use the User:Location field in the view, however this is limited by the formatters provided (i.e not granular)

It seems that this issue was tackled back here: http://drupal.org/node/1064666

Query

SELECT users.name AS users_name, users.uid AS uid, location.city AS location_city, 'user' AS field_data_field_location_profile_user_entity_type, DATE_FORMAT((DATE_ADD('19700101', INTERVAL users.login SECOND) + INTERVAL -18000 SECOND), '%Y%m%d%H%i') AS users_login_minute
FROM 
{users} users
INNER JOIN {users_roles} users_roles ON users.uid = users_roles.uid
LEFT JOIN {location_instance} location_instance ON users.uid = location_instance.uid
LEFT JOIN {location} location ON location_instance.lid = location.lid
WHERE (( (users.status <> '0') AND (users_roles.rid IN  ('4', '5')) ))
ORDER BY users_login_minute DESC

Any help would be greatly appreciated.

ydahi’s picture

I should note that using the User Locations module in place of the CCK field does work.

The reason to use the CCK field instead of the User Locations module:

The field can be neatly tucked into a field group, where as the user location settings display either above or below the rest of the user account fields.

If there was a way to allow for the location fields to be included within a field group, that would be lovely.

glynster’s picture

Thanks for the further explanations on this. All the same problems I have encountered and you are right in that if you used the user location it works well. The only thing we are missing here is a relationship. Once the location module allows a relationship we should be good. Alas not luck as of yet.

jessia’s picture

Yes, I've got the same comments and same issues as ydahi—I can get User Locations to show on a map and get the granular control (city, state, country, etc. as individual fields). I can get the CCK Location for the User to show as an address (or a map, or both), but I can't find a way to pull just the city and country from the address, or to pull the lat/long fields, which I need to place all the user locations on the map.

I am in the process of migrating my site from D6 to D7 and it seemed like the CCK Location was the way to go, but it seems like there are some missing pieces still. I'm guessing the thing to do is to stick with User Locations for now?

ydahi’s picture

I've started building an alternative solution with Address Field with a great deal of success.

There is a very helpful tutorial found here.

joegl’s picture

Issue summary: View changes

I am having the same issue. I can't get the Distance / Proximity filter to work with a CCK Location field on a node.

joegl’s picture

I am still having this issue. How would I use a Distance / Proximity filter on a CCK field location?