Campi obbligatori & fix

This commit is contained in:
2025-09-08 17:38:47 +02:00
parent cbcbcc6f8e
commit 5dec036e78
13 changed files with 711 additions and 114 deletions

View File

@ -13,7 +13,9 @@ $items = $this->items ?? ($this->get('Items') ?? []);
$pagination = $this->pagination ?? ($this->get('Pagination') ?? null);
// Normalizzo items
if (!is_array($items)) { $items = (array) $items; }
if (!is_array($items)) {
$items = (array) $items;
}
$items = array_values(array_filter($items, static fn($it) => is_object($it) && !empty($it->id)));
$Itemid = (int) $input->getInt('Itemid', 0);
@ -37,34 +39,29 @@ $Itemid = (int) $input->getInt('Itemid', 0);
</tr>
</thead>
<tbody>
<?php foreach ($items as $i => $item) : ?>
<?php
$url = Route::_(
'index.php?option=com_circolari&view=circolare'
. '&id=' . (int) $item->id
. '&catid=' . (int) ($item->catid ?? 0)
. ($Itemid ? '&Itemid=' . $Itemid : '')
);
<?php foreach ($items as $i => $item) : ?>
<?php
$url = Route::_('index.php?option=com_circolari&view=circolare&id=' . (int) $item->id);
$title = $item->title ?? ('#' . (int) $item->id);
$hits = isset($item->hits) ? (int) $item->hits : null;
?>
<tr class="cat-list-row<?php echo $i % 2; ?>">
<th class="list-title" scope="row">
<a href="<?php echo $url; ?>">
<?php echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>
</a>
</th>
<td class="text-end">
<?php if ($hits !== null) : ?>
<span class="btn btn-secondary btn-sm disabled" aria-disabled="true">
<?php echo Text::_('JGLOBAL_HITS') ?: 'Visite'; ?>: <?php echo $hits; ?>
</span>
<?php else : ?>
<span class="text-muted">—</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
?>
<tr class="cat-list-row<?php echo $i % 2; ?>">
<th class="list-title" scope="row">
<a href="<?php echo $url; ?>">
<?php echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>
</a>
</th>
<td class="text-end">
<?php if ($hits !== null) : ?>
<span class="btn btn-secondary btn-sm disabled" aria-disabled="true">
<?php echo Text::_('JGLOBAL_HITS') ?: 'Visite'; ?>: <?php echo $hits; ?>
</span>
<?php else : ?>
<span class="text-muted">—</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
@ -82,4 +79,4 @@ $Itemid = (int) $input->getInt('Itemid', 0);
</div>
<?php endif; ?>
</div>
</div>