Last active
May 6, 2016 05:23
-
-
Save Da-Fecto/8d89d6b1d817b3590369 to your computer and use it in GitHub Desktop.
Templates folder switch for ProcessWire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Switch ProcessWire templates directory on $_SERVER['HTTP_HOST']. Type the | |
* Hostname as key and the name of the new templates folder as value. | |
* | |
*/ | |
$config->templates = array( | |
'mobile.domain.dev' => 'templates-mobile', // domain => templates folder name | |
); | |
if (isset($_SERVER['HTTP_HOST']) && isset($config->templates[$_SERVER['HTTP_HOST']], $config->templates)) { | |
foreach ($config->templates as $host => $folder) { | |
if ($_SERVER['HTTP_HOST'] === $host) { | |
// set new paths | |
$config->urls->templates = "/site/" . $folder . "/"; | |
$config->paths->templates = dirname(__DIR__) . $config->urls->templates; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment