You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to generate a link on a custom page (not a cmspage) to point on a cmspage.
I do this :
<a href="{{ path('orbitale_cms_page', {slugs: 'my-page-slug'}) }}">{% trans %}menu.my_page{% endtrans %}</a>
it works perfectly. But. I'm creating a multi-language website. I can't figure out how to deal with the _locale.
As in the database the slug changes depending the language, currently I have to manually, make a condition, to check the current locale and take the good slug, but, obviously this is not a good way to do.
How am I supposed to deal with that? And by the way, I can't find any way to links 2 pages records of different language.
Thank you
The text was updated successfully, but these errors were encountered:
Generating URLs isn't the role of the CmsBundle, it's done with the Symfony Routing component.
Usually, when you use path() or url() in Twig, the _locale parameter is automatically set to the current locale.
Let's say your route path is /{_locale}/some-page, if you are on the /en/some-page page, the _locale parameter will be en, and will automatically be set when generating URLs in your views.
There is currently no way to generate a link for a specific page in your views: as pages are dynamic, you either have to hard-code them (and make sure the Page object exists in the database, and this is your job, not the bundle's one), or find a way to create some kind of "CMS router" that will fit your needs.
You could also create your own Doctrine entities that would have relationships with the Page entity, either via ManyToOne or ManyToMany, and with something like that, you could definitely automatize the process of generating links for these relationships.
Hello
I'm trying to generate a link on a custom page (not a cmspage) to point on a cmspage.
I do this :
it works perfectly. But. I'm creating a multi-language website. I can't figure out how to deal with the _locale.
As in the database the slug changes depending the language, currently I have to manually, make a condition, to check the current locale and take the good slug, but, obviously this is not a good way to do.
How am I supposed to deal with that? And by the way, I can't find any way to links 2 pages records of different language.
Thank you
The text was updated successfully, but these errors were encountered: