Skip to content

Commit

Permalink
Merge pull request #411 from luyadev/issue-409
Browse files Browse the repository at this point in the history
Fix parent nav id assignment in NavItem model
  • Loading branch information
nadar authored Feb 21, 2024
2 parents 1086b5b + f779150 commit c188da6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion src/models/NavItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,17 @@ 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
*/
$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) {
Expand Down

0 comments on commit c188da6

Please sign in to comment.