2

I'm new for OSClass. This code from oc-content\themes\modern\inc.search.php,

<form action="<?php echo osc_base_url(true); ?>" method="get" class="search" onsubmit="javascript:return doSearch();">
    <input type="hidden" name="page" value="search" />
    <fieldset class="main">
        <input type="text" name="sPattern"  id="query" value="<?php echo osc_esc_html( ( osc_search_pattern() != '' ) ? osc_search_pattern() : $sQuery ); ?>" />
        <?php  if ( osc_count_categories() ) { ?>
            <?php osc_categories_select('sCategory', null, __('Select a category', 'modern')); ?>
        <?php  } ?>
        <button type="submit"><?php _e('Search', 'modern'); ?></button>
    </fieldset>
    <div id="search-example"></div>
</form>

Here, i need to add one more option to search. That is Place, same as #query. What can I do?

And where I can make change(s) for good work to this search?

I know following codes,

<input type="text" name="sCity"  id="sCity" value="<?php _e('Enter your city here'); ?>" />

that's give the result like following, enter image description here

But, My requirement is the sCity is also same as sPattern. See the value in both. sPattern shows same result when redirect. but sCity wouldn't. I need that.

KarSho
  • 5,699
  • 13
  • 45
  • 78

2 Answers2

2

This should work

<form action="<?php echo osc_base_url(true); ?>" method="get" class="search" onsubmit="javascript:return doSearch();">
    <input type="hidden" name="page" value="search" />
    <fieldset class="main">
        <input type="text" name="sPattern"  id="query" value="<?php echo osc_esc_html( ( osc_search_pattern() != '' ) ? osc_search_pattern() : $sQuery ); ?>" />
        <input type="text" name="sCity"  id="sCity" value="<?php _e('Enter your city here'); ?>" />
        <?php  if ( osc_count_categories() ) { ?>
            <?php osc_categories_select('sCategory', null, __('Select a category', 'modern')); ?>
        <?php  } ?>
        <button type="submit"><?php _e('Search', 'modern'); ?></button>
    </fieldset>
    <div id="search-example"></div>
</form>

Also, change sCity to sRegion if you prefer to seach by region and not by city

CONEJO
  • 388
  • 1
  • 11
1

For Selectable city field

    <?php $aCities = City::newInstance()->listAll(); ?>
<?php if(count($aCities) > 0 ) { ?>
<select name="sCity" id="sCity">
<option value=""><?php _e('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 } ?>
Key
  • 628
  • 2
  • 7
  • 15