function getCategoryChildren($catid) { static $array = array(); $user =& JFactory::getUser(); $aid = (int) $user->get('aid'); $catid = (int) $catid; $db =& JFactory::getDBO(); $query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering "; $db->setQuery($query); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } foreach ($rows as $row) { array_push($array, $row->id); if (modK2ToolsHelper::hasChildren($row->id)) { modK2ToolsHelper::getCategoryChildren($row->id); } } return $array; }
public static function getCategoryChildren($catid) { static $array = array(); $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $aid = (int) $user->get('aid'); $catid = (int) $catid; $db = JFactory::getDBO(); $query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 "; if (K2_JVERSION != '15') { $query .= " AND access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") "; if ($mainframe->getLanguageFilter()) { $languageTag = JFactory::getLanguage()->getTag(); $query .= " AND language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ") "; } } else { $query .= " AND access <= {$aid}"; } $query .= " ORDER BY ordering "; $db->setQuery($query); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } foreach ($rows as $row) { array_push($array, $row->id); if (modK2ToolsHelper::hasChildren($row->id)) { modK2ToolsHelper::getCategoryChildren($row->id); } } return $array; }
/** * @package Hoxa - Responsive Multipurpose Joomla Template * @author Cththemes - www.cththemes.com * @date: 01-10-2014 * * @copyright Copyright ( C ) 2014 cththemes.com . All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ // no direct access defined('_JEXEC') or die; $categories = JFactory::getApplication()->getMenu()->getActive()->params->get('categories'); require_once JPATH_SITE . DS . 'modules' . DS . 'mod_k2_tools' . DS . 'helper.php'; $cats = array(); foreach ($categories as $cat) { $subCat = modK2ToolsHelper::getCategoryChildren($cat); $cats = array_merge($cats, $subCat); array_unshift($cats, $cat); } $cats = array_unique($cats); ?> <!-- Start K2 Generic (search/date) Layout --> <?php if (count($this->items)) { $total = count($this->items); ?> <?php foreach ($this->items as $key => $item) {