Я реализую пользовательский компонент MVC, следуя документации Joomla 1.6 .
Я сталкиваюсь с проблемой при попытке использовать JCategories::get()
для получения списка категорий и ихдети от com_component
.Я получаю следующую ошибку:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 125306881 bytes)
Если я не выдаю print_r($this->items);
для перечисления элементов, я не получаю ошибку.Если я изменю строку
$categories = JCategories::getInstance('Content');
на чтение
$categories = JCategories::getInstance('banners');
Я не получит ошибку.
Я включил весь свой код компонента ниже.Так же, как к вашему сведению, я провел последние пару дней в irc.freenode.net/#joomla, общаясь с кем-то, кто хотел бы помочь с очень небольшим прогрессом.Любая помощь будет высоко ценится.
Код контроллера:
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import joomla controller library
jimport('joomla.application.component.controller');
$controller = JController::getInstance('CtItem');
$controller->execute(JRequest::getCmd('task'));
$controller->redirect();
Код модели:
<?php
// No direct access to this file
defined('_JEXEC') or die;
// import Joomla Categories library
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;
}
}
Просмотр кода:
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
class CtItemViewCtItem extends JView
{
// Overwriting JView display method
function display($tpl = null)
{
// Assign data to the view
$this->items = $this->get('Items');
if(count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode('<br />', $errors));
return false;
}
// Display the view
parent::display($tpl);
}
}
Код шаблона:
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();
?>
<div id="Test"><?=print_r($this->items, true)?></div>