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

Same alias at root level in different websites is not possible #413

Open
hbugdoll opened this issue Feb 26, 2024 · 4 comments
Open

Same alias at root level in different websites is not possible #413

hbugdoll opened this issue Feb 26, 2024 · 4 comments

Comments

@hbugdoll
Copy link
Member

hbugdoll commented Feb 26, 2024

After #411 we have the following situation now:

Same alias is prevented

  1. with same parent item
  2. or at root level ("same" parent_nav_id = 0).
/* this is possible */                /* this is NOT possible */

Website1                              Website1
├── alias_a                           ├── alias_a
│    ├── alias_b                      │    ├── alias_c
│    └── alias_c                      │    └── alias_c ↯
├── alias_b                           ├── alias_b
│    └── alias_c                      │    └── alias_c
└── alias_c                           └── alias_a ↯

That is the desired behavior.


But there is no support of multiple websites in verifyAlias().
The GROUP BY clause

->groupBy('cms_nav_container.website_id')
doesn't reach it. In my opinion this clause can be omitted because of the presence of ->exists().

Currently, it's not possible to have two pages at root level with same alias but in different websites,
because of "same" parent_nav_id = 0.

/* this is currently NOT possible */

Website1
├── homepage
├── alias_a
│    └── alias_c
└── alias_b

Website2
├── homepage ↯
├── alias_c
│    └── alias_d 
└── alias_b ↯

The WHERE clause

->where(['cms_nav_item.alias' => $alias, 'cms_nav_item.lang_id' => $langId, 'cms_nav.parent_nav_id' => $parentNavId])
should be something like
->where(['cms_nav_item.alias' => $alias, 'cms_nav_item.lang_id' => $langId, 'cms_nav.parent_nav_id' => $parentNavId, 'cms_nav_container.website_id' => $websiteId]) and $websiteId must be provided in verifyAlias().

@nadar
Copy link
Contributor

nadar commented Feb 29, 2024

agree 👍 would you like to send a PR?

@hbugdoll
Copy link
Member Author

I would like to, but it's not clear to me yet how...

$websiteId must be provided in verifyAlias()

  • Passing $websiteId as new argument in NavItem::verifyAlias($alias, $langId, $websiteId) ...ok
  • But how obtaining $websiteId inside NavItem::validateAlias()?
    • Via Yii::$app->website->current['id'] ? Is this corresponding to currentWebsiteToggler or to the website with is_default = 1 ?
    • Using a Query NavItemNavNavContainerWebsite ?

@nadar
Copy link
Contributor

nadar commented Feb 29, 2024

it must be done using:

Using a Query NavItem →Nav →NavContainer → Website

@hbugdoll
Copy link
Member Author

it must be done using:

Using a Query NavItem →Nav →NavContainer → Website

Is not possible, because nav_id is not yet set for the Nav Item when validateAlias() is called during page creating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants