PHPSpert Posted December 19, 2012 Share Posted December 19, 2012 Ok, this might be a little unique, not sure. Basically, I have already accomplished getting PW to use an external path to another domain to grab a directory of global templates I need for this app I'm creating. But now, I also want to allow clients to have local templates. So what I want to do is allow Processwire to search both the local templates dir and the global one on the other domain. Is there a way to do this? There's only one path, but is it possible to include from two paths without re-coding a bunch? Link to comment Share on other sites More sharing options...
ryan Posted December 21, 2012 Share Posted December 21, 2012 I don't know of a way to have ProcessWire keep track of two separate template directories. But of course you can turn any template file into a controller for any number of other template files and include them from wherever you want. A simple example would be to create a template called "external" and add a text field to it called "external_file". Then in your external.php: <?php if($page->external_file) { $filename = "/some/external/path/" . $sanitizer->name($page->external_file) . ".php"; if(is_file($filename)) include($filename); else echo "$filename does not exist"; } else { echo "No external file defined"; } Rather than external_file being a text field, it'd be better as a page reference field connected to a <select>. That way you could select your template rather than having to type it in. But I wanted to keep this example as simple as possible. 2 Link to comment Share on other sites More sharing options...
PHPSpert Posted December 22, 2012 Author Share Posted December 22, 2012 I don't know of a way to have ProcessWire keep track of two separate template directories. But of course you can turn any template file into a controller for any number of other template files and include them from wherever you want. A simple example would be to create a template called "external" and add a text field to it called "external_file". Then in your external.php: <?php if($page->external_file) { $filename = "/some/external/path/" . $sanitizer->name($page->external_file) . ".php"; if(is_file($filename)) include($filename); else echo "$filename does not exist"; } else { echo "No external file defined"; } Rather than external_file being a text field, it'd be better as a page reference field connected to a <select>. That way you could select your template rather than having to type it in. But I wanted to keep this example as simple as possible. Wow - Yes, that's one way to do it. Thanks Ryan, you're a genius. 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