Predisposizione lista circolari
This commit is contained in:
@ -3,35 +3,50 @@ namespace Pcrt\Component\Circolari\Site\View\Circolare;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
protected $item;
|
||||
public $items = [];
|
||||
public $pagination;
|
||||
public $state;
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// Carica la singola
|
||||
$this->item = $this->get('Item');
|
||||
|
||||
if (!$this->item) {
|
||||
throw new \Exception(Text::_('COM_CIRCOLARI_ITEM_NOT_FOUND'), 404);
|
||||
}
|
||||
// Se NON c'è l'item → mostra la lista
|
||||
if (!$this->item) {
|
||||
$app = \Joomla\CMS\Factory::getApplication();
|
||||
$factory = $app->bootComponent('com_circolari')->getMVCFactory();
|
||||
|
||||
// Se il layout non c'è, stampa un fallback minimale (debug-friendly)
|
||||
$tplPath = JPATH_COMPONENT_SITE . '/tmpl/circolare/default.php';
|
||||
if (!is_file($tplPath)) {
|
||||
$title = htmlspecialchars($this->item->title ?? 'Circolare');
|
||||
$body = $this->item->description ?? $this->item->testo ?? $this->item->descrizione ?? '';
|
||||
$html = '<article class="com-content-article item-page">'
|
||||
. '<header class="page-header"><h1 class="page-title">'.$title.'</h1></header>'
|
||||
. '<div class="article-body">'.$body.'</div>'
|
||||
. '</article>';
|
||||
/** @var \Pcrt\Component\Circolari\Site\Model\CircolariModel $model */
|
||||
$model = $factory->createModel('Circolari', 'Site', ['ignore_request' => true]);
|
||||
|
||||
$this->document->setBuffer($html, 'component');
|
||||
return;
|
||||
}
|
||||
// Imposta gli stati MANUALMENTE (niente populateState: è protected)
|
||||
$model->setState('filter.catid', 0); // nessun filtro categoria
|
||||
$model->setState('list.start', 0);
|
||||
$model->setState('list.limit', 0); // 0 = nessun limite (tutte)
|
||||
$model->setState('list.ordering', 'c.id'); // colonna di ordinamento
|
||||
$model->setState('list.direction', 'DESC'); // direzione
|
||||
|
||||
parent::display($tpl);
|
||||
// Recupera i dati
|
||||
$this->state = $model->getState();
|
||||
$this->items = $model->getItems();
|
||||
$this->pagination = $model->getPagination();
|
||||
|
||||
// Usa il layout della lista (tmpl/circolari/default.php)
|
||||
$this->setLayout('default');
|
||||
$this->addTemplatePath(JPATH_COMPONENT_SITE . '/tmpl/circolari');
|
||||
|
||||
return parent::display($tpl);
|
||||
}
|
||||
|
||||
// Rendering normale della singola
|
||||
return parent::display($tpl);
|
||||
}
|
||||
}
|
||||
|
||||
21
site/src/View/Circolari/HtmlView.php
Normal file
21
site/src/View/Circolari/HtmlView.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Pcrt\Component\Circolari\Site\View\Circolari;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
public $items;
|
||||
public $pagination;
|
||||
public $state;
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->state = $this->get('State');
|
||||
$this->items = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
return parent::display($tpl);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user