views:

238

answers:

1

Hi,

I am currently working on a website which lists the businesses as per either their location or the category to which it belongs. Check: http://frugalmillionaire.net/

Existing Functionality implemented (Views, CCK and Taxonomy):

On clicking the Primary Menu Links the Business Category are passed as an argument to the View. Hence the view displays the business listings of the specific category only. Also to implement the Find Local Coupons Block ; a filter of the same view is exposed in a block.

My client wants to give the user the option to set his/her location on the website . Once the user sets that location then upon clicking the links in the primary menu (Restaurant) should list only the restaurants which are of the location set. Similarly clicking on any of the primary menu links should display of the businesses of the location set only.

Potential ways to do it : 1)Set the value selected by the user in the exposed filter. How can this be done? 2) Using Cookies. Can I use the Drupal Cookie to somehow achieve this?

Kindly help me out . Any help/pointers/relevant links would be deeply appreciated.

Thanks

A: 

I think you are asking three different things.

1. How do you get location information from the current user and store it? If the user is setting and forgetting their location, make a Profile Field. The Location module might be of help. If the user just types in a location for temporary usage, save it to their session.

2. How do you theme a site based on the user's location? hook_menu_alter() can be used to change what your primary links are doing based on user data.

3. How do you preload the business Views based on this location?

  1. Invoke the View programmatically, where location information (when available) is inserted in place of the exposed filters. Useful Views Documentation.

  2. Set the relevant information in your View with Arguments. Set the default to the user's location. Because you are relying on a dynamic default, you never need to send a "real" argument to the view.

Grayside
Thanks a lot for taking the time to answer this question. What you are saying is correct. However, after such a clean analysis of the problem you have given I am convinced that achieving it would need quite a bit of coding. Currently I still learning stuff :) . Still Thanks for your reply..
Saurabh
Keep in mind for Component #3 I gave two different options, not two steps toward one solution.
Grayside

related questions