aggiunta vista singola circolare
This commit is contained in:
37
site/src/View/Circolare/HtmlView.php
Normal file
37
site/src/View/Circolare/HtmlView.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user