conf_path() criteria to choose the right website was not useful for us in version 4.7.

  1. We need to distinguish between projects in the same installation, no matter what the URL can be.
    1. URLs always change from development to production.
    2. URLs can be subdomains instead of added paths.
  2. Moreover, folder names under /sites cannot be changed since many URLs inside the CMS depend on that.

All of the above are not well addressed in the current implementation, so we created a patch for the bootstrap.inc adding a simple paragraph at the end of conf_path() function.

It is important to note that this patch is backwards compatible, extending the functionality and not breaking existing configurations.

At line 136, this snippet is inserted

  // fixed location for sites.conf
  $lines = file("$confdir/sites.conf");
 
  for ($i=0 ; $i < count($lines) ; $i++) {
    $line = $lines[$i];
    $line = preg_replace('/#.*$/','',$line); //strip comments
    $line = trim($line); //strip whitespaces
    if (empty($line)) 
      continue; //ignore empty lines
    $lin_temp = explode("=", $line);
    // if current request matches left side of the equation
    if ($lin_temp[0] == "http://".$_SERVER['HTTP_HOST']."/") {
      // set conf file to be the right side of the equation
      $conf = $confdir."/".$lin_temp[1];
      $conf = rtrim($conf);
      if (file_exists($conf)) {
        return $conf;
      }
    }
  }
  // extended algorithm didn't help, continue with existing flow below

With this code, you can add a sites.conf file to the /sites folder, where you tell the system where to find the settings.conf for each of the websites being handled by the base code, specified by URL. An example of such config file is as follows:


# URL of the website = folder to use under /sites
http://helloworld-dev.colaborativa.net/=helloworld
http://helloworld-stg.colaborativa.net/=helloword
http://www.helloworld.com/=helloworld
http://bigbiz-dev.colaborativa.net/=bigbiz
http://www.bigbiz.co.uk/=bigbiz
http://myproject-dev.colaborativa.net/=myproject
http://www.urlofmyproject.tv/=myproject

The example shows how to handle three projects: helloworld, bigbiz and my project in their different scenarios (development, staging and production).

Each line specifies where to find the settings.php

I think there is room for improvement, since this extension makes another call to the filesytem, when it loads the sites configuration file. Perhaps it can be cached someway?

HTH,
--mariano

Comments

dmitrig01’s picture

Status: Needs work » Active

please make a patch in the proper form

dpearcefl’s picture

Status: Active » Closed (won't fix)

Considering the age of this issue with no responses and that D5 is unsupported, I am closing this issue.