Location: PHPKode > projects > injooosm > components/com_injooosm/models/cats.php
<?php
/**
 * Joomla! 1.5 component injooosm
 *
 * @version $Id: cats.php 2009-11-27 20:24:00$
 * @author Christian Knorr
 * @package injooosm
 * @subpackage frontend
 * @license GNU/GPL
 * @filesource
 *
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class injooosmModelCats extends JModel  {

    function getCats()  {
        global $mainframe;

        $db = JFactory::getDBO();

        $query = "SELECT * FROM #__osm_cats"
                . "\n WHERE published=1"
                . "\n ORDER BY ordering";

        $db->setQuery($query);
        $rows = $db->loadObjectList();
        $limit = count($rows);
        $children = array();
	foreach ($rows as $v ) {
		$pt 	= $v->parent;
		$list 	= @$children[$pt] ? $children[$pt] : array();
		array_push( $list, $v );
		$children[$pt] = $list;
	}
        $list = JHTML::_('menu.treerecurse', 0, '', array(), $children );
        $list = array_slice($list,0,$limit);

        return $list;
    }
}
Return current item: injooosm