Advertisement:

Author Topic: [TIP] add Region/State to search bar : converted to Bender  (Read 5181 times)

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
[TIP] add Region/State to search bar : converted to Bender
« on: November 19, 2013, 09:27:28 pm »
here is a fix for the bender theme.

in header.php just after :

Code: [Select]
<div class="cell selector">
      <?php osc_categories_select('sCategory'null__('Select a category''bender')) ; ?>
    </div>

add this:

Code: [Select]
<div class="cell selector">
      <?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>

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: [TIP] add Region/State to search bar : converted to Bender
« Reply #1 on: November 19, 2013, 10:20:37 pm »
Thanks design, minor error: it displays text 'Select a Country', while it displays Regions. Corrected code + country selector:

for Countries
Code: [Select]
<div class="cell selector">
<?php $aCountries Country::newInstance()->listAll(); ?>
<?php if(count($aCountries) > ) { ?>
<select name="sCountry" id="sCountry">
<option value="">Select a Country</option>
<?php foreach($aCountries as $country) { ?>
<option value="<?php echo $country['s_name'] ; ?>"><?php echo $country['s_name'] ; ?></option>
<?php ?>
</select>
<?php ?>
</div>

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

Unfortunatelly this is not a 'smart' code, it lists every region irrespectable of selected country.

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: [TIP] add Region/State to search bar : converted to Bender
« Reply #2 on: November 19, 2013, 10:40:48 pm »
feel free to post something smarter!!

the subject is for state/region not for country, but thank you for posting that code as well, someone will probably need it.
« Last Edit: November 19, 2013, 10:46:43 pm by design »

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: [TIP] add Region/State to search bar : converted to Bender
« Reply #3 on: November 20, 2013, 12:52:19 pm »
Hmm... I thought 'state' was a special case for US, and similar/same as 'country' in english because in Osclass terminology there are regions only. But nevermind :)

There are some topics dealing with smarter code, but did not work for me.

for Cities
Code: [Select]
<div class="cell selector">
<?php $aCities City::newInstance()->listAll(); ?>
<?php if(count($aCities) > ) { ?>
<select name="sCity" id="sCity">
<option value="">Select a City</option>
<?php foreach($aCities as $city) { ?>
<option value="<?php echo $city['s_name'] ; ?>"><?php echo $city['s_name'] ; ?></option>
<?php ?>
</select>
<?php ?>
</div>
« Last Edit: November 20, 2013, 12:54:19 pm by dev101 »

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: [TIP] add Region/State to search bar : converted to Bender
« Reply #4 on: November 20, 2013, 06:54:46 pm »
I know it was strange at first, but certainly not something to get hung up on. ;D

I am working in twitter and modern theme now… this is fun!

eric03

  • Newbie
  • *
  • Posts: 17
Re: [TIP] add Region/State to search bar : converted to Bender
« Reply #5 on: August 19, 2014, 07:34:08 pm »
Hello,
i would like to know it is possible to display only the departments or cities in dropdown from the region selected as homepage for example ?
i use the France theme i would like to do it when i choose a region on the map.
Thanks

pardoido

  • Newbie
  • *
  • Posts: 12
Re: [TIP] add Region/State to search bar : converted to Bender
« Reply #6 on: August 22, 2014, 07:33:23 am »
is there any way to order the regions list alphabetically?

i'm getting
R
L
M
A
T
G
B

and this is very annoying :(

data99

  • Full Member
  • ***
  • Posts: 180
Re: [TIP] add Region/State to search bar : converted to Bender
« Reply #7 on: May 10, 2015, 09:40:12 pm »
now it show all  Region together
this is my code and image attach

Code: [Select]
<?php
    
/*
     *      Osclass – software for creating and publishing online classified
     *                           advertising platforms
     *
     *                        Copyright (C) 2014 OSCLASS
     *
     *       This program is free software: you can redistribute it and/or
     *     modify it under the terms of the GNU Affero General Public License
     *     as published by the Free Software Foundation, either version 3 of
     *            the License, or (at your option) any later version.
     *
     *     This program is distributed in the hope that it will be useful, but
     *         WITHOUT ANY WARRANTY; without even the implied warranty of
     *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *             GNU Affero General Public License for more details.
     *
     *      You should have received a copy of the GNU Affero General Public
     * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="<?php echo str_replace('_''-'osc_current_user_locale()); ?>">
    <head>
        <?php osc_current_web_theme_path('common/head.php') ; ?>
    </head>
<body <?php bender_body_class(); ?>>
<div id="header">
    <!-- header ad 728x60-->
    <div class="ads_header">
    <?php echo osc_get_preference('header-728x90''bender'); ?>
    <!-- /header ad 728x60-->
    </div>
    <div class="clear"></div>
    <div class="wrapper">
        <div id="logo">
            <?php echo logo_header(); ?>
            <span id="description"><?php echo osc_page_description(); ?></span>
        </div>
        <ul class="nav">
            <?php if( osc_is_static_page() || osc_is_contact_page() ){ ?>
                <li class="search"><a class="ico-search icons" data-bclass-toggle="display-search"></a></li>
                <li class="cat"><a class="ico-menu icons" data-bclass-toggle="display-cat"></a></li>
            <?php ?>
            <?php if( osc_users_enabled() ) { ?>
            <?php if( osc_is_web_user_logged_in() ) { ?>
                <li class="first logged">
                    <span><?php echo sprintf(__('Hi %s''bender'), osc_logged_user_name() . '!'); ?>  &middot;</span>
                    <strong><a href="<?php echo osc_user_dashboard_url(); ?>"><?php _e('My account''bender'); ?></a></strong> &middot;
                    <a href="<?php echo osc_user_logout_url(); ?>"><?php _e('Logout''bender'); ?></a>
                </li>
            <?php } else { ?>
                <li><a id="login_open" href="<?php echo osc_user_login_url(); ?>"><?php _e('Login''bender') ; ?></a></li>
                <?php if(osc_user_registration_enabled()) { ?>
                    <li><a href="<?php echo osc_register_account_url() ; ?>"><?php _e('Register for a free account''bender'); ?></a></li>
                <?php }; ?>
            <?php ?>
            <?php ?>
            <?php if( osc_users_enabled() || ( !osc_users_enabled() && !osc_reg_user_post() )) { ?>
            <li class="publish"><a href="<?php echo osc_item_post_url_in_category() ; ?>"><?php _e("Publish your ad for free"'bender');?></a></li>
            <?php ?>
        </ul>

    </div>
    <?php if( osc_is_home_page() || osc_is_static_page() || osc_is_contact_page() ) { ?>
    <form action="<?php echo osc_base_url(true); ?>" method="get" class="search nocsrf" <?php /* onsubmit="javascript:return doSearch();"*/ ?>>
        <input type="hidden" name="page" value="search"/>
        <div class="main-search">
            <div class="cell">
                <input type="text" name="sPattern" id="query" class="input-text" value="" placeholder="<?php echo osc_esc_html(__(osc_get_preference('keyword_placeholder''bender_theme'), 'bender')); ?>" />
            </div>
            <?php  if ( osc_count_categories() ) { ?>
                <div class="cell selector">
                    <div class="cell selector">
<?php $aCountries Country::newInstance()->listAll(); ?>
<?php if(count($aCountries) > ) { ?>
<select name="sCountry" id="sCountry">
<option value="">Select a Country</option>
<?php foreach($aCountries as $country) { ?>
<option value="<?php echo $country['s_name'] ; ?>"><?php echo $country['s_name'] ; ?></option>
<?php ?>
</select>
<?php ?>
</div>
<div class="cell selector">
<?php $aRegions Region::newInstance()->listAll(); ?>
<?php if(count($aRegions) > ) { ?>
<select name="sRegion" id="sRegion">
<option value="">Select a Region</option>
<?php foreach($aRegions as $region) { ?>
<option value="<?php echo $region['s_name'] ; ?>"><?php echo $region['s_name'] ; ?></option>
<?php ?>
</select>
<?php ?>
</div>
                </div>
                <div class="cell reset-padding">
            <?php  } else { ?>
                <div class="cell">
            <?php  ?>
                <button class="ui-button ui-button-big js-submit"><?php _e("Search"'bender');?></button>
            </div>
        </div>
        <div id="message-seach"></div>
    </form>
    <?php ?>
</div>
<?php osc_show_widgets('header'); ?>
<div class="wrapper wrapper-flash">
    <?php
        $breadcrumb 
osc_breadcrumb('&raquo;'falseget_breadcrumb_lang());
        if( 
$breadcrumb !== '') { ?>

        <div class="breadcrumb">
            <?php echo $breadcrumb?>
            <div class="clear"></div>
        </div>
    <?php
        
}
    
?>

    <?php osc_show_flash_message(); ?>
</div>
<?php osc_run_hook('before-content'); ?>
<div class="wrapper" id="content">
    <?php osc_run_hook('before-main'); ?>
    <div id="main">
        <?php osc_run_hook('inside-main'); ?>

thiru_ch

  • Jr. Member
  • **
  • Posts: 75
Re: [TIP] add Region/State to search bar : converted to Bender
« Reply #8 on: May 12, 2015, 01:21:20 pm »
Hi, These codes are working fine.But I want to display only cities of selected Region or State.
Help me.

Thiru