Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parent nav id assignment in NavItem model #411

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading