Advertisement:

Author Topic: (SOLVED) Only display "active" category  (Read 915 times)

Optimus

  • Jr. Member
  • **
  • Posts: 90
(SOLVED) Only display "active" category
« on: August 02, 2013, 12:57:56 am »
Hello,

Seems that if I deactivate a category in Twitter theme, the parent category is still visible when a user tries to post an item. How can I modify that code to only display the categories which are enabled (b_enabled = 1) ?

Code: [Select]
    function item_category_select($default_option) {
        $categories = Category::newInstance()->findRootCategories() ; ?>
        <?php if( count($categories) > ) { ?>
        <select class="category">
            <option><?php echo $default_option ?></option>
            <?php foreach($categories as $c) { ?>
            <option value="<?php echo $c['pk_i_id'] ; ?>"><?php echo $c['s_name'] ; ?></option>
            <?php ?>
        </select>
        <?php ?>
        <select class="subcategory" name="catId" style="display:none"></select>
        <?php
    
}

Thank you in advance
« Last Edit: August 02, 2013, 08:36:09 pm by jimwinny »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Only display "active" category
« Reply #1 on: August 02, 2013, 01:41:34 am »
Hi

Replace 2nd line with:

Code: [Select]
$categories = Category::newInstance()->findRootCategoriesEnabled() ; ?>
Regards

Optimus

  • Jr. Member
  • **
  • Posts: 90
Re: Only display "active" category
« Reply #2 on: August 02, 2013, 08:35:41 pm »
Thank you !!