Advertisement:

Author Topic: Category and subcategory  (Read 1173 times)

fezanna

  • Newbie
  • *
  • Posts: 12
Category and subcategory
« on: March 27, 2014, 03:01:17 pm »
Hi,

I would like to be able to search, first select the category and then the sub-category.

this is the code that right now I show all categories and subcategories.




<select name="sCategory" id="sCategory" class="selectpicker" data-width="100%" >
                     <option value=""><?php _e('Tutte le Categorie', 'metrobar'); ?></option>
                     <?php osc_goto_first_category();
                           while ( osc_has_categories() ) { ?>

                           <optgroup label="<?php echo osc_category_name() ; ?>">

                              <?php  $i = 0; while ( osc_has_subcategories() ) { ?>
                              <option value="<?php echo osc_category_id() ; ?>" <?php if(Params::getParam('sCategory') == osc_category_id()) { ?>selected<?php } ?>><?php echo osc_category_name() ; ?></option>            
                              <?php $i++ ; } ?>
                                 <?php View::newInstance()->_erase('subcategories') ; ?>
                           </optgroup>

   <?php } ?>
</select>

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: Category and subcategory
« Reply #1 on: April 24, 2014, 06:53:02 pm »
you can see in another theme, swap code around ;-)