Jump to content
Sign in to follow this  
darrenc

serve different /site/templates/ based on domain?

Recommended Posts

Standard website lives at www.foobar.com and by default the template files are served up from /site/templates/

Can processwire be set up to serve requests from dev.foobar.com by pulling template files from another directory? /devsite/templates or /site/devtemplate/ ?

Share this post


Link to post
Share on other sites

Place the below in your /site/config.php

// Honour goes to Raymond Geerts for the idea !
$config->templates = array(
    'dev.foobar.com' => 'devtemplate', // 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;
            break;
        }
    }
}
  • Like 7

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...