Search code examples
shopwareshopware6

Shopware 6 use route in cms-text-element/layout


I need to add the following button via text-editor. <a class="btn btn-primary" data-toggle="modal" data-bs-toggle="modal" data-url="path('frontend.cms.page', { id: config('core.basicInformation.contactPage')" href="path('frontend.cms.page', { id: config('core.basicInformation.contactPage')">

But the route can't be resolved. By klicking on the button I get the following erroe message:

No route found for "GET http://.../path('frontend.cms.page',%20%7B%20id:%20config('core.basicInformation.contactPage')" (from "http://.../")

Does anyone know if there is a way to use routes?


Solution

  • You can't use Twig functions inside the text-editor.

    However it is possible by directly using the ID like this:

    <a href="/widgets/cms/a1fe36fee44f41d3a6df0472b0bb49af" title="Contact us" data-toggle="modal" data-url="/widgets/cms/a1fe36fee44f41d3a6df0472b0bb49af">Contact us</a>
    

    You can get the ID from the contact page from the navbar in your browser:

    Get ID from navbar browser