<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_articles_categories
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;                                                                    

foreach ($list as $i => $item) : ?>
	<li <?php if ($_SERVER['REQUEST_URI'] == JRoute::_(ContentHelperRoute::getCategoryRoute($item->id)) || !$i ) echo ' class="active_service"';?>> <?php $levelup = $item->level - $startLevel - 1; ?>
		<a href="javascript:void(0)" data-target="#<?php echo $item->alias; ?>">
		<?php echo $item->title;?>
			<?php if ($params->get('numitems')) : ?>
				(<?php echo $item->numitems; ?>)
			<?php endif; ?>
		</a>   
        <?php if ($params->get('show_children', 0) && (($params->get('maxlevel', 0) == 0)
			|| ($params->get('maxlevel') >= ($item->level - $startLevel)))
			&& count($item->getChildren())) : ?>
			<?php echo '<ul>'; ?>
			<?php $temp = $list; ?>
			<?php $list = $item->getChildren(); ?>
			<?php require JModuleHelper::getLayoutPath('mod_articles_categories', $params->get('layout', 'default') . '_items'); ?>
			<?php $list = $temp; ?>
			<?php echo '</ul>'; ?>
		<?php endif; ?>
        <?php $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true)); ?>
        <?php $model->setState('filter.category_id', $item->id); ?>
        <?php $model->setState('params', JApplication::getInstance('site')->getParams()); ?>
        <?php $articles[ $item->alias ] = $model->getItems(); ?>
	</li>
<?php endforeach; ?>
