Advertisement:

Author Topic: [metro theme] adding dropdown for one category only  (Read 601 times)

cmaltais

  • Newbie
  • *
  • Posts: 14
[metro theme] adding dropdown for one category only
« on: November 21, 2016, 10:45:07 pm »
Hi all,

I'm hoping to get help with adding a dropdown menu with subcategories for ONE specific category. This would be added to the left hand column in search.php. TIA

I tried the code below but it didn't work:

<?php  while(osc_has_categories()) { ?>
    <?php if(osc_category_id() === 98): ?>
        <?php if(osc_count_subcategories() > 0) { ?>
        <ul>
            <?php while(osc_has_subcategories()) { ?>
            <li>
            <strong><a href="<?php echo osc_search_category_url() ?>"><?php echo osc_category_name(); ?></a></strong></label>
            </li>
            <?php } ?>
        </ul>
        <?php } ?>
    <?php endif; ?>
<?php } ?>

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [metro theme] adding dropdown for one category only
« Reply #1 on: November 21, 2016, 11:11:48 pm »
Hi,

Try this way:

Code: [Select]
<?php $current_categories __get('categories');
View::newInstance()->_exportVariableToView('categories'Category::newInstance()->toSubTree(98));
while(
osc_has_categories()) { ?>

    <?php if(osc_category_id() === 98) { ?>
        <?php if(osc_count_subcategories() > 0) { ?>
            <ul>
                <?php while(osc_has_subcategories()) { ?>
                    <li>
                        <strong><a href="<?php echo osc_search_category_url() ?>"><?php echo osc_category_name(); ?></a></strong></label>
                    </li>
                <?php ?>
            </ul>
        <?php ?>
    <?php ?>
<?php }
View::newInstance()->_exportVariableToView('categories'$current_categories); ?>


Regards

cmaltais

  • Newbie
  • *
  • Posts: 14
Re: [metro theme] adding dropdown for one category only
« Reply #2 on: November 22, 2016, 07:31:59 pm »
Thanks very much, but this is still not generating any results for me. I'm wondering if there are issues because I am using metro theme and not something more common. I'll work on finding the discrepancies but if you have any other possible solutions I would love to see them. Thanks again!

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [metro theme] adding dropdown for one category only
« Reply #3 on: November 22, 2016, 08:31:28 pm »
It was your base code, as you wrote it only sub-subcategories (providing "98" be a root category) would be shown. This should give you subcategories and sub-subcategories:

Code: [Select]
<?php $current_categories __get('categories');
View::newInstance()->_exportVariableToView('categories'Category::newInstance()->toSubTree(98));

while(
osc_has_categories()) { ?>

    <ul>
        <li>
            <strong><a href="<?php echo osc_search_category_url() ?>"><?php echo osc_category_name(); ?></a></strong></label>
        </li>
        <?php if(osc_count_subcategories() > 0) { ?>
                <?php while(osc_has_subcategories()) { ?>
                    <li style="padding-left: 10px;">
                        <strong><a href="<?php echo osc_search_category_url() ?>"><?php echo osc_category_name(); ?></a></strong></label>
                    </li>
                <?php ?>
        <?php ?>
    </ul>
<?php }
View::newInstance()->_exportVariableToView('categories'$current_categories); ?>


Regards

cmaltais

  • Newbie
  • *
  • Posts: 14
Re: [metro theme] adding dropdown for one category only
« Reply #4 on: December 28, 2016, 01:31:59 am »
Got it! Thanks very much!