cancel
Showing results for 
Search instead for 
Did you mean: 

Search by category: change option list to multiselect or checkbox

Search by category: change option list to multiselect or checkbox

Hello alltogether,

I have a problem with a search function I want to implent.
From the forums I looked up a way to add a search by category function in the advanced search by following this article:
http://www.magentocommerce.com/wiki/5_-_modules_and_development/search_and_advanced_search/how_to_ad...

However the code for the "form.phmtl" file displays the values as a list. I would like to display it, as a checkbox tree or a multiselect field, where the customer can select multiple categories to search in.

Following you will find the code which display it as a list. Could someone please tell me how do change it as described?

<label for="category_search_field">Search in the following categories</label>
            <select name="category" id="category_search_field">
                <option value="">All</option>
                <?php foreach ($this->getStoreCategories() as $_category): ?>
                <?php if($_category->hasChildren()): ?>
                <option class="parent-cat" value="<?php echo $_category->getId(); ?>"><?php echo $_category->getName();?></option>
                <?php foreach ($_category->getChildren() as $subcategory):
                if($subcategory->getIsActive()) : ?>
                    <option value="<?php echo $subcategory->getId(); ?>"<?php echo ($this->getRequest()->getQuery('category') == $subcategory->getId() ? ' selected="selected"': "") ?>><?php echo $subcategory->getName(); ?></option>
                <?php endif; endforeach; ?>
                <?php elseif($_category->getIsActive()): ?>
                <option value="<?php echo $_category->getId(); ?>"><?php echo $_category->getName();?></option>
                <?php endif; ?>
                <?php endforeach ?>
            </select>
        </li> -->

Thank you very much in advance!

Greetings
NicChew