New language relevant PR in upstream repo: joomla/joomla-cms#48248 Here are the upstream changes:
Click to expand the diff!
diff --git a/administrator/components/com_tags/src/Model/TagModel.php b/administrator/components/com_tags/src/Model/TagModel.php
index b4e1901670743..1f6f51be0db73 100644
--- a/administrator/components/com_tags/src/Model/TagModel.php
+++ b/administrator/components/com_tags/src/Model/TagModel.php
@@ -13,6 +13,8 @@
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Factory;
+use Joomla\CMS\Filter\OutputFilter;
+use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Versioning\VersionableModelTrait;
@@ -249,6 +251,30 @@ public function save($data)
$data['published'] = 0;
}
+ // Automatic handling of alias for empty fields
+ if (\in_array($input->get('task'), ['apply', 'save', 'save2new']) && (!isset($data['id']) || (int) $data['id'] == 0)) {
+ if (empty($data['alias'])) {
+ if (Factory::getApplication()->get('unicodeslugs') == 1) {
+ $data['alias'] = OutputFilter::stringUrlUnicodeSlug($data['title']);
+ } else {
+ $data['alias'] = OutputFilter::stringURLSafe($data['title']);
+ }
+
+ $tagTable = $this->getTable();
+
+ if ($tagTable->load(['alias' => $data['alias'], 'parent_id' => $data['parent_id']])) {
+ $msg = Text::_('COM_TAGS_SAVE_WARNING');
+ }
+
+ [$title, $alias] = $this->generateNewTitle($data['parent_id'], $data['alias'], $data['title']);
+ $data['alias'] = $alias;
+
+ if (isset($msg)) {
+ Factory::getApplication()->enqueueMessage($msg, 'warning');
+ }
+ }
+ }
+
// Bind the data.
if (!$table->bind($data)) {
$this->setError($table->getError());
diff --git a/administrator/components/com_tags/src/Table/TagTable.php b/administrator/components/com_tags/src/Table/TagTable.php
index d130fc92cc0b4..380cd98635b36 100644
--- a/administrator/components/com_tags/src/Table/TagTable.php
+++ b/administrator/components/com_tags/src/Table/TagTable.php
@@ -199,7 +199,7 @@ public function store($updateNulls = true)
// Verify that the alias is unique
$table = new static($this->getDatabase());
- if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) {
+ if ($table->load(['alias' => $this->alias, 'parent_id' => (int) $this->parent_id]) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(Text::_('COM_TAGS_ERROR_UNIQUE_ALIAS'));
// Is the existing tag trashed?
diff --git a/administrator/language/en-GB/com_tags.ini b/administrator/language/en-GB/com_tags.ini
index 81e829358f7fe..4bef32d0dae5a 100644
--- a/administrator/language/en-GB/com_tags.ini
+++ b/administrator/language/en-GB/com_tags.ini
@@ -37,7 +37,7 @@ COM_TAGS_COUNT_UNPUBLISHED_ITEMS="Unpublished items"
COM_TAGS_EMPTYSTATE_BUTTON_ADD="Add your first tag"
COM_TAGS_EMPTYSTATE_CONTENT="Tags in Joomla! provide a flexible way of organizing content. The same tag can be applied to many different content items across content types."
COM_TAGS_EMPTYSTATE_TITLE="No Tags have been created yet."
-COM_TAGS_ERROR_UNIQUE_ALIAS="Another Tag has the same alias."
+COM_TAGS_ERROR_UNIQUE_ALIAS="Another Tag with the same parent tag has the same alias."
COM_TAGS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Tag with the same parent tag has the same alias."
COM_TAGS_EXCLUDE="Exclude"
COM_TAGS_FIELD_CONTENT_TYPE_LABEL="Content types"
@@ -112,6 +112,7 @@ COM_TAGS_REBUILD_FAILURE="Failed rebuilding Tags tree data."
COM_TAGS_REBUILD_SUCCESS="Tags tree data rebuilt."
COM_TAGS_RIGHT="Right"
COM_TAGS_SAVE_SUCCESS="Tag saved."
+COM_TAGS_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the tag to customise the alias."
COM_TAGS_SEARCH_TYPE_LABEL="Match Type"
COM_TAGS_SELECT_TAGTYPE="- Select Tag Type -"
COM_TAGS_SHOW_ALL_TAGS_IMAGE_LABEL="Show Heading Image"
New language relevant PR in upstream repo: joomla/joomla-cms#48248 Here are the upstream changes:
Click to expand the diff!