aggiunta vista singola circolare

This commit is contained in:
2025-08-26 11:18:54 +02:00
parent 1814530c64
commit edb8d4e873
6 changed files with 152 additions and 138 deletions

View File

@ -0,0 +1,37 @@
<?php
namespace Pcrt\Component\Circolari\Site\View\Circolare;
\defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
class HtmlView extends BaseHtmlView
{
protected $item;
public function display($tpl = null)
{
$this->item = $this->get('Item');
if (!$this->item) {
throw new \Exception(Text::_('COM_CIRCOLARI_ITEM_NOT_FOUND'), 404);
}
// 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>';
$this->document->setBuffer($html, 'component');
return;
}
parent::display($tpl);
}
}