<?php

/**

* Author: Gawesh Basnayake

* Email: gaweshademp@yhoo.com

* Module: Sub Items

* Version: 1.3.0

*/



// No Direct Access

defined('_JEXEC') or die('Direct Access to this location is not allowed.');

 

class ModSubItemsHelper

{

  /**

     * Returns a list of post items

    */

    public function getItems($parentId)

    {

        // get a reference to the database

        $db = &JFactory::getDBO();

 

        // get a list of submenus for $parentId

		$query = 'SELECT m.name, m.link, m.id FROM `#__menu` AS m WHERE parent='.$parentId.' ORDER BY ordering';

 

        $db->setQuery($query);

        $items = ($items = $db->loadObjectList())?$items:array();

 

        return $items;

    }

	

	public function getParent($parentId)

	{

        // get a reference to the database

        $db = &JFactory::getDBO();

 

        // get a list of submenus for $parentId

		$query = 'SELECT m.name, m.link FROM `#__menu` AS m WHERE id='.$parentId.' LIMIT 1';

		

		$db->setQuery($query);

        $parent = ($items = $db->loadObjectList())?$items:array();

		

 

        return $parent;

	}

}



?>