Skip to content

Instantly share code, notes, and snippets.

@Da-Fecto
Last active May 6, 2016 05:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Da-Fecto/8d89d6b1d817b3590369 to your computer and use it in GitHub Desktop.
Save Da-Fecto/8d89d6b1d817b3590369 to your computer and use it in GitHub Desktop.
Templates folder switch for ProcessWire
<?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