ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Unable to override template path in config using Multi Site Manager

January 14, 2012 4:17am

Subscribe [2]
  • #1 / Jan 14, 2012 4:17am

    nathanpitman

    531 posts

    I have a site which uses Multi Site Manager and prior to installation of MSM I was overriding the database stored template path value with the config.php file, I’ve found that once MSM is installed that the config override obviously has no context in the control panel, ie the control panel cannot determine ‘which site’ the override relates to.

    I’m assuming there must be some way to work around this but I’ve not found anything in the docs…

    Any help greatly appreciated!

    😊

  • #2 / Jan 15, 2012 8:27am

    Sean C. Smith

    3818 posts

    Hi Nathan,

    After a little investigating and I found a solution posted by Kevin Smith in this thread.

    For the benefit of anyone reading this, here’s what I ended up doing. I make use of this constants.php setup, so in my config.php file, I just use a simple if/then to determine which server I’m on.

    if (SITE === 'expressionengine')
    {
        $config['tmpl_file_basepath']   = "/Users/username/Sites/sandbox/web/system/templates/";
    }
    else
    {
        $config['tmpl_file_basepath']   = "/home/username/public_html/system/templates/";
    }

    Does this work for you?

    Sean

  • #3 / Jan 16, 2012 9:22am

    nathanpitman

    531 posts

    Thanks Sean, I’m not sure this works in my scenario, I have local, staging and live environments that I am catering for in config.php (Note this is an EE1 site) and then on top of that I have MSM installed but admin takes place through only the parent domain. The problem I have is that when you then try to create a template and save it to disk the CP ‘thinks’ the path for the templates is that of the domain through which the administration is taking place, as opposed to the domain/site which you have selected in the MSM drop down menu within the CP. In the end I found a way around this using the following code block in my config.php file:

    if (stripos(strtolower($HTTP_SERVER_VARS['REQUEST_URI']), '/admin/index.php') !== false) {
       // switch to cater for cp template path handling where we have multiple sites
       if ($_REQUEST['exp__cp_last_site_id'] == 1) {
        $conf['tmpl_file_basepath'] = '/Users/Nathan/Sites/domain.com/trunk/public_html/templates';
       } else {
        $conf['tmpl_file_basepath'] = '/Users/Nathan/Sites/domain.com/trunk/public_html/sites/sub_site_1/templates';
       }
      } else {
       $conf['tmpl_file_basepath'] = '/Users/Nathan/Sites/domain.com/trunk/public_html/templates';
      }

    Obviously this would need to be expanded if you had more than just one sub site but it does the job for me! 😊

  • #4 / Jan 20, 2012 7:46pm

    Sean C. Smith

    3818 posts

    Nathan,

    Awesome! Glad I was able to help you out. I’m going to close out this thread, but feel free to post again when you have more questions.

    Sean

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases