Location CCK Views Fix

Simple and easy Location CCK Views Fix with no coding required. This fix is designed for the problem that arises when attempting to use Location data from Location CCK fields in views. The location CCK views module offers some great potential, but one of the major drawbacks is the issues it has with Views. Basically, the location filters do not work so you cannot filter nodes by ‘city’ or ‘province’. Fortunately, this was very easily fixed for me and I suspect it will be for you as well simply using relationships in views. Follow this guide to fix the issue and get your views showing nodes and other resources sorted by city, state, etc.

To start, create a content type of some kind that includes location CCK fields. For this particular example I have chosen to create a content type called activity. Here is an example of the CCK fields with some locations added:
Location CCK Fields

Now, after creating this content type as an example, go to a view that you wish to use to filter content by location.
Step 1: Create a relationship

Click the plus sign along the top of the relationship box.
Location CCK Fields

Tick ‘Content: Activity Location (field_activity_locations)’ where “field_activity_locations” will be the name of the CCK field on the content. Then click Add.
Location CCK views relationship

Another window will then load, which will allow you to configure the view. I generally just click update without ticking the ‘require’ box. Then click update.
Step 2: Create a Location Filter

Click the + symbol at the top off the filter box.
Location CCK Filter start

In the add filter settings, choose one of the ‘Location: ____’ filter by ticking the box next to it. For this example I am going with Location: Country. Then click Add.
Location CCK add filter
Step 3: Link the Relationship

This is the really IMPORTANT step. Under the relationship label, click down the drop-box and and choose ‘Location’. Then click update. Now the Location CCK and Location modules are linking their data for this display, at last. If you want the filter to be able to be chosen by users, click the expose button to expose it and then click unlock operator.
Location relationships
Finished:

Now, the filter should work and content will be filtered by the CCK country location field. Pretty simple overall and no coding required.
views location fixed

Related posts: