I need to display content with the frontend theme in an admin page to get a preview. I get the content and built it with the ->getViewBuilder('node') but the template used is coming from the admin theme and the created template in the frontend theme node--newsletter.html.twig is not taken into account.

enter image description here

Is there a way to see the node view mode with the frontend theme instead of the admin theme ?

Thank you.


If this is a custom route (defined in a routing.yml file with a custom controller) you are able to do this by defining the route in the routing yaml with

    _admin_route: FALSE

Which will cause the route to be treated as a "frontend" route. However it sounds like this is likely not the case here.

If you simply want to have previewing of standard content, the core preview function (the button next to "Save") is the standard mechanism to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.