Assegnazione url corretto alla singola circolare

This commit is contained in:
2025-08-26 16:59:53 +02:00
parent 2f251bbfb0
commit 16ac92a59e
9 changed files with 200 additions and 8 deletions

View File

@ -18,6 +18,14 @@
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC" />
<field
name="catid"
type="category"
extension="com_content"
label="JCATEGORY"
required="true"
default="11"
/>
<field name="description" filter="safehtml" type="textarea" label="COM_CIRCOLARI_FORM_LBL_CIRCOLARE_DESCRIPTION" description="COM_CIRCOLARI_FORM_DESC_CIRCOLARE_DESCRIPTION" hint="COM_CIRCOLARI_FORM_LBL_CIRCOLARE_DESCRIPTION"/>
<field name="attachment" type="media"
label="COM_CIRCOLARI_FIELD_ATTACHMENT_LABEL"

View File

@ -0,0 +1,9 @@
ALTER TABLE `#__circolari`
ADD COLUMN `catid` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `modified_by`,
ADD INDEX `idx_catid` (`catid`);
ALTER TABLE `#__circolari`
ALTER `catid` SET DEFAULT 11;
-- opzionale, porta a 11 i record con catid 0/null
UPDATE `#__circolari` SET `catid` = 11 WHERE `catid` IS NULL OR `catid` = 0;

View File

@ -21,7 +21,7 @@ use \Joomla\CMS\Helper\TagsHelper;
use \Joomla\CMS\Filter\OutputFilter;
use \Joomla\CMS\Event\Model;
use Joomla\CMS\Event\AbstractEvent;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Application\ApplicationHelper;
/**
@ -127,6 +127,14 @@ class CircolareModel extends AdminModel
$data = $this->item;
}
if ((is_array($data) && empty($data['id'])) || (is_object($data) && empty($data->id))) {
if (is_array($data)) {
$data['catid'] = (int)($data['catid'] ?? 0) ?: 11;
} else {
$data->catid = (int)($data->catid ?? 0) ?: 11;
}
}
return $data;
}

View File

@ -198,7 +198,7 @@ class CircolareTable extends Table implements VersionableTableInterface, Taggabl
$this->ordering = self::getNextOrder();
}
// Ordering per nuovi record
// Ordering per nuovi record
if (property_exists($this, 'ordering') && (int) $this->id === 0) {
$this->ordering = self::getNextOrder();
}
@ -235,6 +235,11 @@ class CircolareTable extends Table implements VersionableTableInterface, Taggabl
}
// Default categoria (nuovi record o catid non impostato)
$this->catid = (int)($this->catid ?? 0) ?: 11;
return parent::check();
}
@ -313,5 +318,4 @@ class CircolareTable extends Table implements VersionableTableInterface, Taggabl
$this->_db->setQuery($q);
return ((int) $this->_db->loadResult()) > 0;
}
}

View File

@ -36,6 +36,7 @@ HTMLHelper::_('bootstrap.tooltip');
<legend><?php echo Text::_('COM_CIRCOLARI_FIELDSET_CIRCOLARI'); ?></legend>
<?php echo $this->form->renderField('title'); ?>
<?php echo $this->form->renderField('alias'); ?>
<?php echo $this->form->renderField('catid'); ?>
<?php echo $this->form->renderField('description'); ?>
<?php echo $this->form->renderField('attachment'); ?>
<?php echo $this->form->renderField('image'); ?>