adrianmak Posted January 15, 2015 Share Posted January 15, 2015 as title Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted January 15, 2015 Share Posted January 15, 2015 Yes, as far as I know. Maybe there is some way to overrule that, but the mainstream way is to put them in tempates site/templates folder. Link to comment Share on other sites More sharing options...
Raymond Geerts Posted January 15, 2015 Share Posted January 15, 2015 Basicly you have one folder for templates by default. This is configured to be in "site root" + templates/ You are able to overrule this setting from the site/config.php as follow $config->urls->templates = $config->urls->site . 'mytemplates/'; $config->paths->templates = $config->paths->site . 'mytemplates/'; A trick i use a lot when developing in a live site is to duplicate the template folder and rename the copy to templates-dev. Then make sure i have an other domain (or subdomain) pointing to the hosting, for example dev.domain.ext and for the live site on www.domain.ext With the following code i can access the development templates while normal visitors keep getting the default templates. /** * Development: Alias for template-dev access * */ if($_SERVER['HTTP_HOST'] == 'dev.domain.ext') { $config->urls->templates = $config->urls->site . 'templates-dev/'; $config->paths->templates = $config->paths->site . 'templates-dev/'; $config->debug = true; } You can make up all kind of 'rules' to go by when overruling the templates folder with php from the config.php file. For example serving the same site with different layout and code for mobile on m.domain.ext /** * Mobile: Alias for template-mobile access * */ if($_SERVER['HTTP_HOST'] == 'm.domain.ext') { $config->urls->templates = $config->urls->site . 'templates-mobile/'; $config->paths->templates = $config->paths->site . 'templates-mobile/'; } 25 Link to comment Share on other sites More sharing options...
marcus Posted January 15, 2015 Share Posted January 15, 2015 Amazing approach. Can I add this as a recipe? 8 Link to comment Share on other sites More sharing options...
Raymond Geerts Posted January 15, 2015 Share Posted January 15, 2015 @marcus sure, please do 2 Link to comment Share on other sites More sharing options...
marcus Posted January 15, 2015 Share Posted January 15, 2015 @marcus sure, please do Thanks! 2 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted January 15, 2015 Share Posted January 15, 2015 I think maybe the original question was not about changing the path to the folder where templates reside, but rather about being able to put template files in different subfolders of site/templates (or something different, adjusted with the methods, described above). Although you can change the file used as template file for the template in Admin -> Setup -> Templates -> Edit Template on the Files tab, you cannot point to something like "views/product/product.php" there as far as I know (at least it did not work when I tried). You can only choose different file in template folder. It could be just great if you could. 2 Link to comment Share on other sites More sharing options...
szabesz Posted June 12, 2019 Share Posted June 12, 2019 On 1/15/2015 at 5:38 PM, Ivan Gretsky said: you cannot point to something like "views/product/product.php" there as far as I know Just want to add for anyone reading this post, that while in the admin this cannot be done, it is doable via code. By putting something like this into init.php,: $templates->get('home')->filename = $config->paths->templates . 'views/home/home.php'; it is possible to store a template file wherever you want. Read more about this in this topic: https://processwire.com/talk/topic/2676-configuring-template-path/ 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now