diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e9f6c2..983c5e56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ In order to read more about upgrading and BC breaks have a look at the [UPGRADE ## 5.1.1 + [#410](https://github.com/luyadev/luya-module-cms/pull/410) Disabled sorting functionality for the "group" extra field in the block CRUD interface due to an exception being thrown. This issue occurred because the field is declared as an `extraAttribute`. ++ [#409](https://github.com/luyadev/luya-module-cms/issues/409) Implemented a new validation check to prevent slug duplication within the same language and navigation hierarchy when creating a new page. This enhancement ensures unique page identification and avoids conflicts in site structure. ## 5.1.0 (7. February 2024) diff --git a/src/models/NavItem.php b/src/models/NavItem.php index 2a6aa496..007ed741 100644 --- a/src/models/NavItem.php +++ b/src/models/NavItem.php @@ -256,6 +256,9 @@ public function verifyAlias($alias, $langId) return false; } + // when no parent nav id is given, the post value is `null` therefore we have the explicit set the value to `0`. + $parentNavId = $this->parent_nav_id ?: 0; + /** * Group by website_id * @since 4.0.0 @@ -263,7 +266,7 @@ public function verifyAlias($alias, $langId) $exists = static::find() ->leftJoin('cms_nav', 'cms_nav_item.nav_id=cms_nav.id') ->leftJoin('cms_nav_container', 'cms_nav.nav_container_id=cms_nav_container.id') - ->where(['cms_nav_item.alias' => $alias, 'cms_nav_item.lang_id' => $langId, 'cms_nav.parent_nav_id' => $this->parent_nav_id]) + ->where(['cms_nav_item.alias' => $alias, 'cms_nav_item.lang_id' => $langId, 'cms_nav.parent_nav_id' => $parentNavId]) ->groupBy('cms_nav_container.website_id') ->exists(); if ($exists) {