I am implementing a custom MVC component after the Joomla 1.6 documentation .
I am having a problem when trying to use JCategories::get()to get a list of categories and their children from com_component. I get the following error:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 125306881 bytes)
If I do not issue print_r($this->items);to list the elements, I do not receive an error message. If I changed the line
$categories = JCategories::getInstance('Content');
to read
$categories = JCategories::getInstance('banners');
I do not get an error.
I have included all my component code below. Like FYI, I spent the last couple of days at irc.freenode.net/#joomla talking with anyone who wants to help with very little progress. Any help would be greatly appreciated.
Controller Code:
<?php
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controller');
$controller = JController::getInstance('CtItem');
$controller->execute(JRequest::getCmd('task'));
$controller->redirect();
Model Code:
<?php
defined('_JEXEC') or die;
jimport( 'joomla.application.categories' );
class CtItemModelCtItem extends JModel
{
private $_items = null;
private $_parent = null;
public function getItems($recursive = false)
{
$categories = JCategories::getInstance('Content');
$this->_parent = $categories->get(15);
if(is_object($this->_parent))
{
$this->_items = $this->_parent->getChildren($recursive);
}
else
{
$this->_items = false;
}
return $this->_items;
}
}
View code:
<?php
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');
class CtItemViewCtItem extends JView
{
function display($tpl = null)
{
$this->items = $this->get('Items');
if(count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode('<br />', $errors));
return false;
}
parent::display($tpl);
}
}
Template Code:
<?php
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();
?>
<div id="Test"><?=print_r($this->items, true)?></div>