Advertisement:

Author Topic: Cities dropdown based on Region Select  (Read 36433 times)

wakaka

  • Newbie
  • *
  • Posts: 9
Re: Cities dropdown based on Region Select
« Reply #30 on: April 08, 2013, 08:55:24 am »
But using original category select didn`t remember what we select. How to make it remember what we have been select?

geo78

  • Full Member
  • ***
  • Posts: 100
Re: Cities dropdown based on Region Select
« Reply #31 on: April 08, 2013, 04:20:52 pm »
But using original category select didn`t remember what we select. How to make it remember what we have been select?

 <?php osc_categories_select('sCategory', null, __('Select a category', 'modern')) ; ?> is default in modern theme for categories.

I have used @cartagena68's code in inc.search.php and search.php. After submit search in homepage, the next page's url has "&page=search&sPattern=gibson&sCategory=97&sRegion=742322&sCity=44727&sPriceMin=&sPriceMax=#.UWKzGFdy1gs. Now if you use the same code from inc.search.php in search.php (criteria sidebar), the sregion is remembered but scity nope. Also, if i repeat search from criteria (select Region and City), the generated url after submit looks like:?page=search&sOrder=dt_pub_date&iOrderType=desc&sPattern=gibson&sRegion=742322&sCity=&sPriceMin=&sPriceMax=&sCategory[]=97&
You can see that the sCity value is not passed in the url.

Finally, the dropdowns values are the region and city ids. That works fine for search BUT it seems that the default search method is to use the city and region names. You can see that by pressing the city name in breadcrumbs.

cartagena68

  • issues
  • Hero Member
  • *
  • Posts: 1198
Re: Cities dropdown based on Region Select
« Reply #32 on: April 08, 2013, 09:36:40 pm »
@ geo78

If i understud you want the drop down in sidebar of search.php
I dont know if is possible to use it.
I'm using classic theme and the inc.search.php is on every page, so the drop down is allready in header section of search.php also, the sidebar search is just for refine search.
In modern theme inc.search.php is only in main page.
You can try, if you like, to do the same in modern theme, keep the original search.php sidebar and add the inc.search.php in every page.
You just need to add the code

Code: [Select]
<?php osc_current_web_theme_path('inc.search.php') ; ?>
in your header.php where you like to show the search bar (usually just before the widgets code "<?php osc_show_widgets('header') ; ?>" ) and delete the same code (<?php osc_current_web_theme_path('inc.search.php') ; ?>) from main.php

Like that you have the drop down in every page.


@ wakaka

i'm trying to see if i can do something for subcategory, if i'll came up with something i will post it here
« Last Edit: April 08, 2013, 09:39:40 pm by cartagena68 »

geo78

  • Full Member
  • ***
  • Posts: 100
Re: Cities dropdown based on Region Select
« Reply #33 on: April 09, 2013, 12:44:30 am »
@ geo78

If i understud you want the drop down in sidebar of search.php
I dont know if is possible to use it.
I'm using classic theme and the inc.search.php is on every page, so the drop down is allready in header section of search.php also, the sidebar search is just for refine search.
In modern theme inc.search.php is only in main page.
You can try, if you like, to do the same in modern theme, keep the original search.php sidebar and add the inc.search.php in every page.
You just need to add the code

Code: [Select]
<?php osc_current_web_theme_path('inc.search.php') ; ?>
in your header.php where you like to show the search bar (usually just before the widgets code "<?php osc_show_widgets('header') ; ?>" ) and delete the same code (<?php osc_current_web_theme_path('inc.search.php') ; ?>) from main.php

Like that you have the drop down in every page.


@ wakaka

i'm trying to see if i can do something for subcategory, if i'll came up with something i will post it here

Thanks for the suggestion but even though i have moved the inc.search.php in header (removed from main.php) the city is not remembered at the next page.

I will search a little more about this and if i dont find what is wrong, i wll remove city in both inc.search and search.php

geo78

  • Full Member
  • ***
  • Posts: 100
Re: Cities dropdown based on Region Select
« Reply #34 on: April 09, 2013, 01:42:56 am »
@cartagena68

In your site after you search with dropdowns, the region and city are remembered in the sidebar(textfields). Now if you press the search button at the end of the sidebar, the url is different and that means dublicate page

cartagena68

  • issues
  • Hero Member
  • *
  • Posts: 1198
Re: Cities dropdown based on Region Select
« Reply #35 on: April 09, 2013, 03:37:03 am »
@ geo78

I think that inc.search.php and search.php are a little different.
With inc.search.php you can search with regions and cities IDs, i dont know if is possible also using the search sidebar.
I used the cities Ids to solve the problem with the duplicate city names all around USA.
Before, if i search in a city that have a duplicate name in other state, give me "no results".

The 2 pages are different becouse inc.search.php use cities and regions IDs and sidebar use cities and regions names, i don't know if this will create any problem.

to remeber the city name in sidebar you should have in the input value "<?php echo osc_search_city() ; ?>"

If you look at the end of the sidebar i also list the cities with ads in the searched region

mon

  • Jr. Member
  • **
  • Posts: 83
Re: Cities dropdown based on Region Select
« Reply #36 on: May 10, 2013, 02:32:51 am »
Ive used the code cartagena68 provided the 3th april.
The dropdown city box based on region is working well but the cities are not displayed alphabetically.
Im sure this is easy to solve but ive tried fixing it and couldnt find the solution.

Can someone help?  :)

AGoGo

  • Full Member
  • ***
  • Posts: 148
  • AGoGo
Re: Cities dropdown based on Region Select
« Reply #37 on: May 25, 2013, 08:36:37 pm »
Hi guys I have a problem
my regions and cities do not match someone know how to fix this problem



does not hook the selection of countries regions and cities

I beg you

AGoGo

  • Full Member
  • ***
  • Posts: 148
  • AGoGo
Re: Cities dropdown based on Region Select
« Reply #38 on: May 25, 2013, 08:59:41 pm »
if someone corrects me these 3 files I would be very grateful

Dhileep

  • Newbie
  • *
  • Posts: 19
Re: Cities dropdown based on Region Select
« Reply #39 on: July 24, 2013, 06:17:09 pm »
if i used this script in search.php then check box in that page is not working (in firefox browser)

ravinderpayal

  • Newbie
  • *
  • Posts: 2
Re: Cities dropdown based on Region Select
« Reply #40 on: October 06, 2013, 01:39:15 pm »
hi i have also a problem in item post and item edit the regions and cities are not selectable and on mouse over there is a cross like "(/)".
i also have tried  <?php ItemForm::location_javascript(); ?>  (my theme is twitter(repurpose) and i can't find  <?php ItemForm::location_javascript_new(); ?> in any file so i place this line " <?php ItemForm::location_javascript(); ?>" without replacing any other).
After placing this line there was two problems:-
problem 1:  subcategories not appear on electing categories.
problem 2:  regions and cities not update according to selection of countries.(there are states of first country. i.e. the country listed in top and don't update they remains same)
I hope any one helps me.
I also want to tell that in admin panel the cities and regions update according to countries as well regions.
My web site is  http://www.funnenjoy.com/classifieds

lexosc

  • Sr. Member
  • ****
  • Posts: 344
Re: Cities dropdown based on Region Select
« Reply #41 on: October 17, 2013, 04:22:37 pm »
@cartagena68 thanks for your code it works well for me! Do you know how can i add a country dropdown too? i added a dropdown but i think it needs some more code and js it doesn't update  regions based on countires
Code: [Select]
<?php $aCountries Country :: newInstance()->listAll();?>
        <?php if (count($aCountries) > 0) {?>
        <select name="sCountry" id="sCountry">
        <option value="">Select Country</option>
        <?php foreach ($aCountries as $Country) {?>
        <option  value="<?php echo $Country['s_name'];?>"><?php echo $Country['s_name'];?></option>
        <?php ?>
        </select>

        <?php ?>
« Last Edit: October 17, 2013, 04:25:39 pm by alexgr »

cartagena68

  • issues
  • Hero Member
  • *
  • Posts: 1198
Re: Cities dropdown based on Region Select
« Reply #42 on: October 17, 2013, 08:27:42 pm »
@cartagena68 thanks for your code it works well for me! Do you know how can i add a country dropdown too? i added a dropdown but i think it needs some more code and js it doesn't update  regions based on countires
Code: [Select]
<?php $aCountries Country :: newInstance()->listAll();?>
        <?php if (count($aCountries) > 0) {?>
        <select name="sCountry" id="sCountry">
        <option value="">Select Country</option>
        <?php foreach ($aCountries as $Country) {?>
        <option  value="<?php echo $Country['s_name'];?>"><?php echo $Country['s_name'];?></option>
        <?php ?>
        </select>

        <?php ?>

Hi alexgr,
i have only une country each site, so i never tryed to add country and i don't know how do it.
You can try to look this post at the reply #5
http://forums.osclass.org/general-help/how-to-auto-complete-country-region-city-city-area-filters-for-main-page-search/
may help you

yellow53

  • Full Member
  • ***
  • Posts: 142
Re: Cities dropdown based on Region Select
« Reply #43 on: December 13, 2013, 11:18:59 am »
Hi cartagena68,

I really like your select2 option, but I would like to use it on the seach_list.php page...on the side bar menu.

only for Region + City and I have only categories (no sub)

Do you think you could help me on this ?

Many thanks,
Vincent

cartagena68

  • issues
  • Hero Member
  • *
  • Posts: 1198
Re: Cities dropdown based on Region Select
« Reply #44 on: December 13, 2013, 10:05:18 pm »
Hi Vincent,
i don't know if is possible to use for search-sidebar.
I think search-sidebar is nice like that with autocomplete.