Hi,
I'm facing a problem, when I select a category it shows items for this category but in the dropdown it doesn't keep selected category and shows "All categories" instead of selected one.
Please help me to solve this problem so the selected category still shown after selecting.
My function is :
<?php
function dropdown_category( ) {
$categories = Category::newInstance()->toTree();
$html = '<select class="sCategory" id="sCategory" name="sCategory">';
$html .= '<option value="" >' . __('All categories', 'veronika') . '</option>';
foreach($categories as $c) {
$sscategories = Category::newInstance()->findSubcategoriesEnabled( $c['pk_i_id'] );
$html .= '<option class = "bldd" ' . ($c['s_name'] == Params::getParam('sCategory') ? ' selected="selected"' : '') . ' value="' . $c['pk_i_id'] . '">---' . $c['s_name'] . '---</option>';
foreach( $sscategories as $ss ) {
$html .= '<option ' . ($ss['s_name'] == Params::getParam('sCategory') ? ' selected="selected"' : '') . ' value="' . $ss['pk_i_id'] . '">' . $ss['s_name'] . '</option>';
}
}
$html .= '</select>';
return $html;
}
?>