Advertisement:

Author Topic: required Side search bar drop down for city & region.  (Read 2978 times)

Quikb.com

  • Jr. Member
  • **
  • Posts: 69
required Side search bar drop down for city & region.
« on: February 25, 2014, 05:03:36 am »
hi dear all

i am new to this site/forum. i have installed a site i want to make side search bar for country/region/city as dropdown. kindly help.

i am using os Version 3.3.2 with Twitter Theme.

Kindly refer attachment photo for better clarity.

S.Trajkov

  • Newbie
  • *
  • Posts: 11
Re: required Side search bar drop down for city & region.
« Reply #1 on: March 25, 2014, 07:08:37 pm »
I am looking for this option for months, and i did not find a solution. Is there anyone who can help ?!

Thank you! :)

innoserv

  • Newbie
  • *
  • Posts: 45
Re: required Side search bar drop down for city & region.
« Reply #2 on: April 01, 2014, 04:22:40 am »
hi friends

first go to the theme folder and open the file  search.php and find this code

Code: [Select]
<input type="text" name="sCity" id="sCity" value="<?php echo osc_search_city() ; ?>" />
replac it with this one

Code: [Select]
<h4><?php _e('City''twitter') ; ?></h4>
<div class="controls">
                                    <?php if($edit){ 
                                   
ItemForm::city_select() ; 
                                } else {  
                                   
ItemForm::city_select(osc_get_cities(), osc_user()) ; 
                                } 
?>

                                </div>

this is for city the same ting for the region i hope tha this code help it work with me good luck if you don t fix it tell me and i will send you the code completly

for the region add tis code before the city

Code: [Select]
<div class="cell selector">
      <h4><?php _e('Region''twitter') ; ?></h4>
      <?php $aRegions Region::newInstance()->listAll(); ?>
      <?php if(count($aRegions) > ) { ?>
      <select name="sRegion" id="sRegion">
        <option value="">Select a State</option>
        <?php foreach($aRegions as $region) { ?>
        <option value="<?php echo $region['s_name'] ; ?>"><?php echo $region['s_name'] ; ?></option>
        <?php ?>
      </select>
      <?php ?>
</div>

if you don t get good resuelt you can cope this code in your search.php it s the same code in my local web

Code: [Select]

<!DOCTYPE html>
<html dir="ltr" lang="<?php echo str_replace('_''-'osc_current_user_locale()); ?>">
    <head>
        <?php osc_current_web_theme_path('head.php') ; ?>
        <?php if(osc_count_items() == 0) { ?>
            <meta name="robots" content="noindex, nofollow" />
            <meta name="googlebot" content="noindex, nofollow" />
        <?php } else { ?>
            <meta name="robots" content="index, follow" />
            <meta name="googlebot" content="index, follow" />
        <?php ?>
    </head>
    <body>
        <?php osc_current_web_theme_path('header.php') ; ?>
        <div class="container margin-top-10">
            <?php twitter_show_flash_message() ; ?>
        </div>
        <!-- content -->
        <div class="container container-fluid search">
            <?php echo twitter_breadcrumb('&raquo;') ; ?>
            <!-- sidebar -->
            <div class="sidebar well">
                <form action="<?php echo osc_base_url(true); ?>" method="get">
                    <input type="hidden" name="page" value="search" />
                    <fieldset>
                        <h4><?php _e('Your search''twitter') ; ?></h4>
                        <div class="clearfix">
                            <input type="text" name="sPattern" id="query" value="<?php echo osc_search_pattern() ; ?>" />
                        </div>
                    </fieldset>
                    <fieldset>
                       
                        <div class="clearfix">
<div class="cell selector">
<h4><?php _e('Region''twitter') ; ?></h4>
  <?php $aRegions Region::newInstance()->listAll(); ?>
  <?php if(count($aRegions) > ) { ?>
  <select name="sRegion" id="sRegion">
<option value="">Select a State</option>
<?php foreach($aRegions as $region) { ?>
<option value="<?php echo $region['s_name'] ; ?>"><?php echo $region['s_name'] ; ?></option>
<?php ?>
  </select>
  <?php ?>
</div>
<h4><?php _e('City''twitter') ; ?></h4>
                            <div class="controls">
                                    <?php if($edit){ 
                                   
ItemForm::city_select() ; 
                                } else {  
                                   
ItemForm::city_select(osc_get_cities(), osc_user()) ; 
                                } 
?>

                                </div>
                        </div>
                    </fieldset>
                    <?php
                        View
::newInstance()->_erase('subcategories') ;
                        
View::newInstance()->_erase('categories') ;
                    
?>

                    <?php if ( osc_count_categories() ) { ?>
                    <fieldset>
                        <h4><?php _e('Categories''twitter') ; ?></h4>
                        <div class="clearfix">
                            <ul class="inputs-list">
                            <?php // RESET CATEGORIES IF WE USED THEN IN THE HEADER ?>
                            <?php osc_goto_first_category() ; ?>
                                <?php while( osc_has_categories() ) { ?>
                                <li>
                                    <label>
                                        <?php
                                            $rootCategory 
Category::newInstance()->findSubcategories(osc_category_id()) ;
                                            
$isParent     false ;
                                            foreach(
$rootCategory as $c) {
                                                if( 
in_array($c['pk_i_id'], osc_search_category()) ) {
                                                    
$isParent true ;
                                                }
                                                if( 
in_array($c['s_slug'], osc_search_category()) ) {
                                                    
$isParent true ;
                                                }
                                            }
                                        
?>

                                        <input type="checkbox" id="cat<?php echo osc_category_id(); ?>" name="sCategory[]" value="<?php echo osc_category_id(); ?>" <?php echo ( (in_array(osc_category_id(), osc_search_category()) || $isParent || in_array(osc_category_slug(), osc_search_category()) || count(osc_search_category()) == )  ? 'checked' '') ; ?> />
                                        <span><?php echo osc_category_name(); ?></span>
                                    </label>
                                </li>
                                <?php ?>
                            </ul>
                        </div>
                    </fieldset>
                    <?php ?>
                    <?php
                        
if(osc_search_category_id()) {
                            
osc_run_hook('search_form'osc_search_category_id()) ;
                        } else {
                            
osc_run_hook('search_form') ;
                        }
                    
?>

                    <div class="clearfix">
                        <button class="btn" type="submit"><?php _e('Apply''twitter') ; ?></button>
                    </div>
                </form>
                <?php osc_alert_form() ; ?>
            </div>
            <!-- sidebar end -->
            <div class="content">
                <?php require('search_list.php') ; ?>
            </div>
        </div>
        <?php osc_current_web_theme_path('footer.php') ; ?>
    </body>
</html>

« Last Edit: April 01, 2014, 04:37:35 am by innoserv »

praveend06

  • Newbie
  • *
  • Posts: 29
Re: required Side search bar drop down for city & region.
« Reply #3 on: July 14, 2014, 01:16:21 pm »
This code works fin ebut after submitting search form region and city get reset.

These should show selected.

omid_firoznia

  • Newbie
  • *
  • Posts: 37
Re: required Side search bar drop down for city & region.
« Reply #4 on: January 20, 2019, 08:42:46 pm »
Hi

Here is the solution:

go to theme folder search-sidebar.php put
below code after {{{       <div id="sidebar">     }}}}

<?php
    if (bender_default_location_show_as() == 'dropdown') {
        ItemForm::location_javascript();
    } else {
        ItemForm::location_javascript_new();
    }
    ?>

and also change below code :

            <h3><?php _e('City', 'bender'); ?></h3>
            <div class="row">
                <input class="input-text" type="hidden" id="sRegion" name="sRegion" value="<?php echo osc_esc_html(Params::getParam('sRegion')); ?>" />
                <input class="input-text" type="text" id="sCity" name="sCity" value="<?php echo osc_esc_html(osc_search_city()); ?>" />
            </div>

to-->

<h3><div class="box location">
                            <h2><?php _e('Listing Location', 'bender'); ?></h2>
                            <?php if(count(osc_get_countries()) > 1) { ?>
                            <div class="control-group">
                                <label class="control-label" for="country"><?php _e('Country', 'bender'); ?></label>
                                <div class="controls">
                                    <?php ItemForm::country_select(osc_get_countries(), osc_user()); ?>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="regionId"><?php _e('Region', 'bender'); ?></label>
                                <div class="controls">
                                    <?php
                                    if (bender_default_location_show_as() == 'dropdown') {
                                        if($edit) {
                                            ItemForm::region_select(osc_get_regions(osc_item_country_code()), osc_item());
                                        } else {
                                            ItemForm::region_select(osc_get_regions(osc_user_field('fk_c_country_code')), osc_user());
                                        }
                                    } else {
                                        if($edit) {
                                            ItemForm::region_text(osc_item());
                                        } else {
                                            ItemForm::region_text(osc_user());
                                        }
                                    }
                                    ?>
                                </div>
                            </div>
                            <?php
                            } else {
                                $aCountries = osc_get_countries();
                                $aRegions = osc_get_regions($aCountries[0]['pk_c_code']);
                                ?>
                            <input type="hidden" id="countryId" name="countryId" value="<?php echo osc_esc_html($aCountries[0]['pk_c_code']); ?>"/>
                            <div class="control-group">
                                <label class="control-label" for="region"><?php _e('Region', 'bender'); ?></label>
                                <div class="controls">
                                  <?php
                                    if (bender_default_location_show_as() == 'dropdown') {
                                        if($edit) {
                                            ItemForm::region_select($aRegions, osc_item());
                                        } else {
                                            ItemForm::region_select($aRegions, osc_user());
                                        }
                                    } else {
                                        if($edit) {
                                            ItemForm::region_text(osc_item());
                                        } else {
                                            ItemForm::region_text(osc_user());
                                        }
                                    }
                                    ?>
                                </div>
                            </div>