Welcome Guest, Not a member yet? Register   Sign In
multiple sites, 1 codebase, using symlinks (with smarty)
#12

[eluser]Vince Stross[/eluser]
I use a similar architecture with a single code base and sym links, etc. I've updated the index.php file for each site to include additional constant variables:

Code:
define('JASMINEROOT', $_SERVER['DOCUMENT_ROOT']);
define('JASMINEPATH', JASMINEROOT."/application");

The "/application" folder is an extremely slimmed version of a default "application" folder. I do not call mine "application" for security reasons but for this post I changed it for clarification purposes. This folder has a "views" folder for custom views for this site and a "config" folder. In the config folder I have all the config files from a standard CI install. In order for the custom config for each site to work I have to change the config files in the core code base "application/config" folder as follows:

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

if(defined('JASMINEROOT')){include_once(JASMINEROOT.'/rabbit_hole/config/config.php');}

else{

/*

|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://www.your-site.com/
|
*/
$config['base_url']    = "http://www.domain.com/";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "index.php";

/*
.... rest of config.php ....

}

?>

You can do this with any of your config files, including routes.php

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

if(defined('JASMINEROOT')){include_once(JASMINEROOT.'/rabbit_hole/config/routes.php');}
else{
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
|     www.your-site.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
|    http://ellislab.com/codeigniter/user-guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are two reserved routes:
|
|    $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
|    $route['scaffolding_trigger'] = 'scaffolding';
|
| This route lets you set a "secret" word that will trigger the
| scaffolding feature for added security. Note: Scaffolding must be
| enabled in the controller in which you intend to use it.   The reserved
| routes must come before any wildcard or regular expression routes.
|
*/
$route['default_controller'] = "home";
$route['scaffolding_trigger'] = "";
}

?>

So in other words: I can load my codebase as a site in itself, or I can call it from another site. If I am calling it from another site, the constants are set and each config file will check for the constants and if exist, load the config files from the appropriate site.

Hope this helps!


Messages In This Thread
multiple sites, 1 codebase, using symlinks (with smarty) - by El Forum - 04-09-2008, 06:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB