views:

139

answers:

1

Hi,

First thing I would say is that I am a Drupal newbie. So, I would appreciate your answer in a detailed step by step process.

I am using Drupal 6 and location module. There are two main content types - user profile (using content profile module) and event content type. Both have one field for location.

Now, lets suppose in his profile, user is selecting city as Toronto and province as Ontario. And some events have been added for Toronto city. I need one Views, which will display events from user city. So, if user is from Vancouver, and they click on "my city events", they will see list of events from their city. Someone told me that I can achieve this using arguments/ relationships, but I don't know how to do that.

Can someone please help me out? I am not good at PHP either :(

A: 

The simplest (but maybe not optimal) way of doing this is to add a 'City' argument to the view. This is done in the Views configuration page, in the Arguments section. You just need to select the field to be used as an argument. In your case this would be the 'City' field of the 'Event' content type.

After adding this argument, if the view is displayed, for example, under the path '/my-city-events', you'd have to pass the city of the user as an argument in this URL, like '/my-city-events/Vancouver'.

So, for the user to see the events of his city, you'd need to provide him with a link containing the city that is in his profile. I'm not sure how the Content Profile module works, but basically you'd need to do some PHP programming to get the user's city and create the correct link.

A better approach would be to automatically get the user city from his profile, instead of passing it in the URL. I'm not sure how this could be done without any programming, but this module may help, if you want try: http://drupal.org/project/user_relationships

Vinicius Pinto
Thanks. I will try this out and let you know.
Joseph