Closed rzp-789 closed 1 year ago
Hi @rzp-789,
have you tried removing the prefix on route in your config/routes/monsieurbiz_sylius_cms_page_plugin.yaml
?
monsieurbiz_cms_page_admin:
resource: "@MonsieurBizSyliusCmsPagePlugin/Resources/config/routing/admin.yaml"
prefix: /%sylius_admin.path_name%
monsieurbiz_cms_page_shop:
resource: "@MonsieurBizSyliusCmsPagePlugin/Resources/config/routing/shop.yaml"
Hi @delyriand , thanks for your answer. And yes it's the first think i did but it's not enough.
What is your issue, what happens when you try to go the the URL of your page ? 404 ? 500 ? With more details we will be able to help you more easily.
We managed to disable CMS pages' localized URLs on a project without specific issue.
so i follow this doc to disable local ( https://docs.sylius.com/en/1.9/cookbook/shop/disabling-localised-urls.html ), and i remove prefix like @delyriand recommand me above. I create a page nommed "test". And i get a 404 No route found for "GET https://localhost/test"
If you run bin/console debug:router | grep cms
what is the result of that ?
I can see :
monsieurbiz_cms_page_show GET ANY ANY /{slug}
Be sure your route is loaded.
yes i have the same result
monsieurbiz_cms_page_admin_page_index GET ANY ANY /admin/pages/
monsieurbiz_cms_page_admin_page_create GET|POST ANY ANY /admin/pages/new
monsieurbiz_cms_page_admin_page_update GET|PUT|PATCH ANY ANY /admin/pages/{id}/edit
monsieurbiz_cms_page_admin_page_bulk_delete DELETE ANY ANY /admin/pages/bulk-delete
monsieurbiz_cms_page_admin_page_delete DELETE ANY ANY /admin/pages/{id}
monsieurbiz_sylius_cms_page_ajax_generate_page_slug GET ANY ANY /admin/page/generate-slug
monsieurbiz_cms_page_show GET ANY ANY /{slug}
we work on a channel with only fr_FR local, maybe come frome there ? because i need to fill the channel when i create my page on admin
we work on a channel with only fr_FR local, maybe come frome there ? because i need to fill the channel when i create my page on admin
Is your page enabled and assigned to the channel?
yes everything seems good in DB
Check the https://github.com/monsieurbiz/SyliusCmsPagePlugin/blob/master/src/Routing/PageSlugConditionChecker.php Try to debug on it to check if it's called and if your route condition is :
condition: "context.checkPageSlug(request)"
Maybe you have another class which decorates router.request_context
?
I think i find something wrong when i dump on vendor/monsieurbiz/sylius-cms-page-plugin/src/Routing/RequestContext.php function checkPageSlug line 79. i GET True at the condition so it's return "false"
Be careful of die on your example because some partial URLs are rendered and they call the context.
ok i want to do but i don't really understand why it's dangerous in this case because nothing is personnal, and finally i found it's this condition on vendor/monsieurbiz/sylius-cms-page-plugin/src/Routing/RequestContext.php => function checkPageSlug line 79. Who return false and doesn't render the page but i would prefere not change the condition ...
i finish by decorate directly router.request_context by mine and change the condition who block me. Thanks for your help ;-).
Hi @rzp-789,
Could you provide the override you've made please? At least we could understand the issue.
Thank you!
I changed the condition who compared 2 object request of function checkPageSlug, by something more specific like the PathInfo maybe it's not the better way but it's functionnal for my project :
/**
* @param Request $request
*
* @return bool
*/
public function checkPageSlug(Request $request): bool
{
if ($request->getPathInfo() !== $this->requestStack->getMainRequest()->getPathInfo()) {
return false;
}
return $this->pageSlugConditionChecker->isPageSlug($this->prepareSlug($request->getPathInfo()));
}
Just a question, did you change the yaml in
https://docs.sylius.com/en/1.9/cookbook/shop/disabling-localised-urls.html
With this line I had some issue with this router in my memory, so I removed it :
locale_switcher: storage
yes i changed it, so you tell me without this line i don't need to override the router.request_context ?
Yup.
With this line :
Without I have a 200 with my page
damn, i loose some much time because of this. Always stay alert with sylius doc. Thanks for your tips
We have an issue open on this topic https://github.com/Sylius/Sylius/issues/12227
I would want to remove the localCode in Url for the page created with this bundle, do you know a way to do this properly ? I tried but everytime i can't refind my CmsPage if i removed the localCode on my Sylius Application. Thanks for your help.