How can I set the user selected value of an exposed location Views filter for the entire Drupal 6 website? - drupal

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

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?
Invoke the View programmatically,
where location information (when
available) is inserted in place of
the exposed filters. Useful Views Documentation.
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.

Related

How to display teasers (fields), dependent of conditions user put into webform in Drupal 7?

I want to make site that displays form, and makes user capable to input certain parameters in it. For example, real estate site. Let say I have these fields among others: location, price, size. If user choose to see houses under 100 000$, Drupal has to back node teasers (fields) for houses only under that price.
Now, I wonder how to make Views module start searching when user click submit button, and how to make conditions under which Views search, dynamically dependent of parameters users put into form.
Do I need some additional modules beside Views and Webform modules? Or maybe, I don't need them? Maybe I have to write some php/mysql script that do searching and fetching, but, naturally, I think Views module is build for that kind of circumstances. Thanks in advance!
1) There is an option in Views when you create the exposed filters: "Remember the last selection". This caches the user selection for each Views and when user visits the Views again he will see the previous filters enabled.
2) For better UX you can use Better_Exposed_Filters and Views_Saved_Searches modules. With the first one you have much more options for exposed filters (eg expose as checkboxes) and with the last one users can save their searches and use them later (like bookmarking a url path).
PS. I don't think using the Webform module with views will be useful in order to create personal saved searches. Instead, Views Saved Searches is what you are looking for.

Drupal 6.x Add More Module - No end to adding more

Simple question for all of you here dealing with Drupal 6.x...
With Drupal's Add More module, is there a way to configure my webform so that there is no limit on how many of a specific fields I can add more of?
Please see my image for example:
For example, I'd like to enable the user to add as many titles as they would like. Is that doable?
Unfortunately, it's not currently possible to add unlimited "add another" functionality with webforms. And if this functionality does become a reality someday, I doubt it will be backported to the Drupal 6 version of the module. From the webform modules author (quicksketch):
there is no progress on this subject. The ability to support multiple
values requires a tremendous amount of re-architecting, including
changes to the way CSVs are generated, analysis, the database
structure, and the UI (both for administrators and users). I wouldn't
expect this feature to be added any time soon.
See this thread for more information:
http://drupal.org/node/354381
I would suggest using a node and the CCK module plus rules and views to collect this information.
Assumptions:
Anonymous users can fill out the current form
You need some way of retrieving the data that is submitted
Regular users of the site should not be able to view submissions
Very loose directions:
Create a content type and add all of the fields that your current webform contains to it. CCK has the ability to store unlimited values out of the box. On the field settings page, inside the Global Settings fieldset, select "Unlimited" for the "Number of Values" field.
Give anonymous users permission to Create [your-new-content-type] Content on the Role Permissions page.
Using the Rules module, create a new triggered rule that fires on "Content is about to be viewed" with an condition "Content has type [your-new-content-type]" and an action of redirect to homepage (or a custom error page that you created). (Note: this is a bit of a performance hit. There are better ways to restrict access to this content type, but for the sake of this tutorial, this was the easiest to explain)
Using the Views module, create a new view with Style set to Table. Add each of the fields in [your-new-content-type] in the fields section. Under "Access" choose "role" and select the role that is assigned to your user. Add a "page" display, give it a Path and save. This is the page you will use to view submissions.
Optional:
Use the Rules module to send yourself (or the submitter) an email when a node of [your-new-content-type] is created.

Arrange drupal 7 people/users admin page

I want to arrange the people's section of my drupal 7 admin page. Right now, the People/users are arranged according to usernames, status, roles, member for, ....etc. I want to make it look like last name, first name, employee id, ....etc (these are custom profile fields.) Then finally I want to arrange it alphabetically according to their last name. I have tried using views but ended up with the following two issues: 1. I couldn't find the custom profile fields like the first name, last name, ...etc, and 2. I have to either create a page or block to access the results of the views page (I want to make everything in the people's page.) I would real appreciate your help!!!
If you're referring to /admin/people, you can create a page and use that path in your view, and it'll override the default /admin/people page. This is an explicit feature of the views module.
Bear in mind you'll have to mimic all the existing functionality you want to keep from the admin/people page (eg exposed filters and sorting), and make sure you set the access permissions on the view to ensure only admin users have access.
As for not being able to see custom profile fields, do you mean they're not showing up in the list of fields to select? I don't know why that would be... if you've created a view based on Users, then the fields will show up under the "User" category (User: first name, User: last name &c). I've checked my own install and everything's showing up fine. Further info?

Drupal only display certain content based on location

I need to be able to only display certain content/nodes based on where a user is located in the world. For example, if the user is from the US, they should see different results than someone from Europe.
Ideally I would be able to tag each node with the region(s) that it should be displayed in and then when the content is displayed, it is filtered by these tags.
I'm also going to be using various content 'scrollers' to display content and I would like these to have different content based on location as well.
How would I best achieve this?
Use Views - and cool modules like:
Use modules like smart_ip http://drupal.org/project/smart_ip & Ip Geolocation http://drupal.org/project/ip_geoloc
Read the info on those module pages they will help you get on the right track
Basically you want to first get the location of the user, this will be stored in the session.
once you have that you can reference it any time.
I know this is an old thread, but it's one that doesn't necessarily have an easy solution in Drupal. Here's how I did it. This solution doesn't match the original question exactly, but this explains a method that could be extended to cover that scenario by extending the PHP code to compare the user's location to the taxonomy term(s) assigned to each node.
First, install IP2Country. This allows you to match an IP address to someone's country by doing a geolocation lookup.
Second, use PHP code like this to determine if the visitor's IP address matches a certain country. This example returns true if the visitor is in the US or Canada, and false if they are not.
<?php
$detectedcountry = module_invoke('ip2country','get_country',$_SERVER['REMOTE_ADDR']);
$countries = array(
'US','CA'
);
if(in_array($detectedcountry,$countries)){
return true;
}
else return false;
?>
You can use this code in various places, but you will need to enable the PHP filter module for it to work.
In my solution, I used this code in two ways:
First, I created a Panels Variant for a Node Template (could be a Taxonomy Term template as well) to return a HTTP response rather than a Panel Pane. I used this code as a selection rule, so it would return a 404 if the user was not in a country that was allowed to see that specific node type. I then created Panels variant that returned the node page for anyone who qualified based on their location.
Second, I created a Panels variant for a node type (Product, in this case) and used the same PHP code to hide certain elements on the page for those users who weren't allowed to see them because of their location. In this case, I hid the Price and Add to Cart panes on a product display page. Visitors outside the allowed countries only saw the product information, and not the ecommerce elements on the page.
As a third option, you could also use it to show/hide Drupal blocks using the same code.
Finally, I created a custom theme function so I could show/hide individual menu items depending on a person's location. In this case, I wanted to hide the Shop menu item unless you were in the permitted countries. I wrote about how to do that in more detail here: https://fiveminutelessons.com/learn-drupal-sitebuilding/show-or-hide-menu-item-drupal-7-based-users-location

How I can add "files available for download" to Drupal user profile page

first time here. I have searched all day for my particular issue with no luck.
I have users that have specific roles auto generated (they purchase a game). I want to display files available to their particular role on their user profile page. I just want to know how I can add a generic view or associate a panel with user profile pages. I want this to display for every user, not on a per user basis. Basically it'll act like, say, direct2drive, you log in and go to your user profile basically and see what games you bought. Seems simple but I am having a heck of a time figuring out how to do this.
I am pretty used to using views but I just don't get how to edit the user profiles like I want to.
Thanks!
The simplest way is to install views_attach, and create a view with a Profile display. This displays the View on the user profile pages, rather than on its own page or in a block, and will pass the user's uid to the View as an argument.
Alternatively, if you're already using comfortable using panels, you can go to admin/build/panels and enable the Users panel. This replaces the user profile page with a panel, which you can add views, nodes and blocks to as normal.

Resources