简体   繁体   中英

Symfony 4 set Twig template path in controller

I searched everywhere but unfortunately without result. The case is as following: I'm using a general Symfony 4 codebase with basic TWIG template files. Next to that i have multiple domains who refer to the codebase, because of that reason I want to set the path to my TWIG files in the controller from my codebase: return $this->render("path/to/domain/and/twig/temp", "domain variables");

This is not working and I can't find how to change my TWIG path withing my controller. Can somebody help with this?

Thanks!

Symfony uses app/Resources/views/ directory for templates. If you want to change you can configure it in config.yml as below.

twig:
    # ...
    paths: ["%kernel.project_dir%/templates"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM