Closed (outdated)
Project:
Location
Version:
6.x-3.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Aug 2009 at 21:59 UTC
Updated:
19 Jul 2016 at 12:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
blueblade commentedi would like to know how to do this too =)
Comment #2
j0rd commented+1 needing to know how to do this. I can't figure it out either.
Comment #3
marqpdx commentedI would like to limit countries to only those which are part of the dataset the view represents. Say we have 100 nodes to search from, and they are hotels in 30 counties, and i want to expose the Location (Country/City). can we limit the country's in the exposed filter dropdown only to the 30 in the dataset, instead of all of them??
thanks,
m
Comment #4
rooby commentedIn the function location_get_iso3166_list in location.inc is the list of countries.
You can comment out the ones you don't want. Just put // at the start of the lines with the countries you don't want in the list.
Comment #5
rooby commentedChanging this to a feature request.
Administrators should be able to select, from the list of all countries, which countries will be options in the country field.
Comment #6
solona commentedThank you, this helped.
Comment #7
toemaz commentedSee http://evolvingweb.ca/story/form-alter-node-locations for the form alter snippet.
Comment #8
ambientdrup commentedThese are great tweaks/fixes but they don't solve for this case:
What if we want to allow admins to post both international and US locations using the drop down (for country), but only allow our site visitors to search via an exposed location country drop down that only shows the international locations (but not the US). I have 2 exposed block Views - one for searching US state and one for searching International. So on the international one I want all the countries to show up except for United States.
Can we just remove one of the countries from the exposed View?
-backdrifting
Comment #9
toemaz commented@backdrifting hook_form_alter will save your day
Comment #10
ambientdrup commentedOk, cool. I'd stick the form_alter in the Views module correct? Or would I add it to location?
I only want to alter the output of the exposed drop down form in the view.
-backdrifting
Comment #11
ambientdrup commentedWill hook_form_alter work even though it's a drop down select list?
-backdrifting
Comment #12
ambientdrup commentedOk I've added the following to my template.php file in the theme folder but I can't get the print_r to work:
and this is the function to print_r:
What am I doing wrong here? I'm pretty sure this is the name of the View block form - I got this from the form id in view source.
-backdrifting
Comment #13
toemaz commentedHere is an example with hook_form_alter for exposed filter
Comment #14
ambientdrup commentedOk, I'll try this. So this should go in the views.module file? Or should I create a custom module file for it?
-backdrifting
Comment #15
ambientdrup commentedThe problem is - is this going to override and make tweaks to the country location form used in the location module as part of the create content form? I just want to remove a country from the exposed view filter but not from the location module country select list.
-backdrifting
Comment #16
toemaz commentedAdd it in a custom module 'yoursite'.module and no, it will only affect your exposed views. Just give it a try.
Comment #17
ambientdrup commentedCool. Ok, I'll try it. Thanks so much.
-backdrifting
Comment #18
ambientdrup commentedHmmm ... I've uploaded the module and tried this but it's not affecting the exposed filter. All countries are still showing.
-backdrifting
Comment #19
mandclu commentedSubscribing. It would be great to have an easy way to do this.
Comment #20
Anonymous (not verified) commented+1
tried the function in a custom module but countries are still showing. maybe I need to flush some caches (although I am in theme devel mode and no caching)
selecting the available countries on Location CCK would be a good improvement. I guess this hack will limit the countries in ALL Location select inputs? I just need it in a single node field.
IMHO Location CCK is powerful but still not flexible enough. In my wish-list: select list for provinces and auto-fill with zip code entered, out of the box.
Comment #21
kndrIn my opinion, abillity to limit countries is very usefull and sometimes neccessary. I am attaching the patch with my own proposal.
Comment #22
aniebel commentedTested the patch in #21. I was able to enter my chosen countries in the Admin interface however, I was unable to view ONLY those countries. It's still showing everything in both the Views Proximity Filter list and on the resulting View.
Comment #23
kndrIndeed, #21 wasn't designed to work with views.
Comment #24
awasson commentedSubscribing: Would like to limit countries to those available in the existing nodes. So if there are no nodes "located" in Japan, Japan will not be in the location: country filter but as soon as I create a node that is "located" in Japan, it (Japan) will become available in the filter.
Comment #25
Anonymous (not verified) commentedsubscribing - I would like to just show US and Canada in the country list for Content Profile.
Comment #26
Anonymous (not verified) commentedI know this doesn't give admins the ability to easily change the list of available countries...but it is a way to achieve it easily. With very little headache I implemented this on one of my sites.
http://drupal.stackexchange.com/questions/4559/how-to-alter-country-drop...
Comment #27
awasson commentedHey, thanks for sharing that link.
The article shows how you can create a simple module that populates the drop down menu that you specify with a tailor made list. It's actually pretty neat but it would be even more useful if it were extended to loop through the database and populate the drop-down with only countries that are relevant to the content in question.
I don't (think I) have the time right now to explore that at the moment but I think it could work and I'll investigate a little more as soon as I can free up some time.
Andrew
Comment #28
iRex commentedsubscribing
Comment #29
NewZeal commentedI found that in hook_form_alter, the country selects are not visible and used the following hook instead (Make sure the weight of your module is greater than the weight of the location module):
The same hook can be used to change a lot of other features of the module such as the field labels for the form. See the function location_locationapi().
Comment #30
legolasboClosing old D6 issues as D6 is end of life