diff --git a/site/src/Model/CircolariModel.php b/site/src/Model/CircolariModel.php deleted file mode 100644 index b970660..0000000 --- a/site/src/Model/CircolariModel.php +++ /dev/null @@ -1,59 +0,0 @@ -getDatabase(); - $q = $db->getQuery(true) - ->select('c.*') // evita errori per colonne mancanti - ->from($db->quoteName('#__circolari') . ' AS c'); - - // Colonne realmente presenti - $cols = array_change_key_case( - $db->getTableColumns($db->replacePrefix('#__circolari'), false), - CASE_LOWER - ); - - // Stato (solo se esiste la colonna) - if (isset($cols['state'])) { - $q->where('COALESCE(c.state, 1) = 1'); - } - - // Filtro categoria (solo se esiste colonna e valore) - $catid = (int) $this->getState('filter.catid', 0); - if ($catid > 0 && isset($cols['catid'])) { - $q->where('c.catid = ' . $catid); - } - - // Ordinamento (ripiega su id se la colonna non c'è) - $orderCol = (string) $this->getState('list.ordering', 'c.id'); - $orderDir = strtoupper((string) $this->getState('list.direction', 'DESC')) === 'ASC' ? 'ASC' : 'DESC'; - $orderKey = ltrim(str_ireplace('c.', '', $orderCol)); - if (!isset($cols[strtolower($orderKey)])) { - $orderCol = 'c.id'; - } - $q->order($db->escape($orderCol . ' ' . $orderDir)); - - return $q; - } - - public function getItems() - { - $items = parent::getItems(); - if (!is_array($items)) { - return []; - } - // Filtra eventuali elementi nulli/invalidi - return array_values(array_filter($items, static function ($it) { - return is_object($it) && isset($it->id) && (int) $it->id > 0; - })); - } -} diff --git a/site/src/View/Circolare/HtmlView.php b/site/src/View/Circolare/HtmlView.php index 4e8a012..3250dd8 100644 --- a/site/src/View/Circolare/HtmlView.php +++ b/site/src/View/Circolare/HtmlView.php @@ -1,4 +1,5 @@ item = $this->get('Item'); // Se NON c'è l'item → mostra la lista - if (!$this->item) { - $app = \Joomla\CMS\Factory::getApplication(); - $factory = $app->bootComponent('com_circolari')->getMVCFactory(); - - /** @var \Pcrt\Component\Circolari\Site\Model\CircolariModel $model */ - $model = $factory->createModel('Circolari', 'Site', ['ignore_request' => true]); - - // 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 - - // 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); -} + if (!$this->item) { + $this->setLayout('default'); + $this->addTemplatePath(JPATH_COMPONENT_SITE . '/tmpl/circolari'); + return parent::display($tpl); + } // Rendering normale della singola return parent::display($tpl); diff --git a/site/src/View/Circolari/HtmlView.php b/site/src/View/Circolari/HtmlView.php index 64b5742..a9fd67b 100644 --- a/site/src/View/Circolari/HtmlView.php +++ b/site/src/View/Circolari/HtmlView.php @@ -7,15 +7,8 @@ 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); + return parent::display($tpl); // il template carica i moduli } } diff --git a/site/tmpl/circolare/default.php b/site/tmpl/circolare/default.php index 3744677..2844f16 100644 --- a/site/tmpl/circolare/default.php +++ b/site/tmpl/circolare/default.php @@ -7,20 +7,20 @@ use Joomla\CMS\Language\Text; /** @var \Pcrt\Component\Circolari\Site\View\Circolare\HtmlView $this */ $item = $this->item; ?> -
- -
- description ?: $item->testo ?: $item->descrizione ?: '(Nessun testo)'; ?> +
+ +
+
+

escape($item->title); ?>

+
+ +
+ Condividi +
+
+ description ?: $item->testo ?: $item->descrizione ?: '(Nessun testo)'; ?> +
- attachment)) : ?> -

- - - -

- -
+ \ No newline at end of file diff --git a/site/tmpl/circolari/default.php b/site/tmpl/circolari/default.php index c8882fb..dcf57aa 100644 --- a/site/tmpl/circolari/default.php +++ b/site/tmpl/circolari/default.php @@ -1,43 +1,16 @@ items ?? []; -if (!is_array($rows)) $rows = (array) $rows; -$rows = array_values(array_filter($rows, static function ($it) { - return is_object($it) && !empty($it->id); -})); +// posizione dove pubblichi il tuo modulo (es. mod_circolari) +$position = 'circolari-list'; -$Itemid = (int) (Factory::getApplication()->input->getInt('Itemid') ?: 0); -?> -
- -

- - - -
+$modules = ModuleHelper::getModules($position); // rispetta l'assegnazione alla voce di menu attiva +if (empty($modules)) { + echo '
Nessun modulo assegnato alla posizione "' . htmlspecialchars($position) . '".
'; +} else { + foreach ($modules as $module) { + echo ModuleHelper::renderModule($module, ['style' => 'xhtml']); // oppure 'none', 'html5', ecc. + } +}