<?php
/**
 * @package    JBusinessDirectory
 *
 * @author CMSJunkie http://www.cmsjunkie.com
 * @copyright  Copyright (C) 2007 - 2021 CMSJunkie. All rights reserved.
 * @license   https://www.gnu.org/licenses/agpl-3.0.en.html
 */
defined('_JEXEC') or die('Restricted access');

if (empty($span)) {
	$span = "col-xl-3 col-lg-4 col-sm-6 col-12";
}
?>
<div class="row categories-style-5" >
    <?php $k = 0; ?>
    <?php foreach ($categories as $category) {
	if (!is_array($category)) {
		$category = array($category);
		$category["subCategories"] = array();
	}
	if (isset($category[0]->name)) {
		$k++; ?>
            <div class="<?php echo $span?>">
                <b>
                    <a href="<?php echo $category[0]->link ?>"><?php echo $category[0]->name ?>
                        <?php if ($appSettings->show_total_business_count) { ?>
                            <span class="numberCircle"> <?php echo $category[0]->nr_listings ?></span>
                        <?php } ?>
                    </a>
                </b>
                
                <?php $i=1; ?>
                <?php foreach ($category["subCategories"] as $cat) { ?>
                    <a title="<?php echo $cat[0]->name?>" alt="<?php echo $cat[0]->name?>"
                       href="<?php echo $cat[0]->link ?>">
                        <?php echo $cat[0]->name?>
                    </a>
                <?php } ?>
            </div>
        <?php
	} ?>
    <?php
} ?>
</div>