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

[eluser]CodeOfficer[/eluser]
A closer look at my (GLOBAL) application folder:

Code:
cache
    SMARTY SPECIFIC FOLDER with write access
config
    standard codeigniter
configs
    SMARTY SPECIFIC FOLDER
controllers
    NOT USED GLOBALLY - EACH SITE HAS ITS LOCAL CONTROLLERS FOLDER
    FOLDER IS ACTUALLY EMPTY
errors
    standard codeigniter
helpers
    standard codeigniter
hooks
    standard codeigniter
libraries
    contains a wrapper class called MySmarty.php for smarty useage
models
    standard codeigniter
templates
    SMARTY SPECIFIC FOLDER
templates_c
    SMARTY SPECIFIC FOLDER with write access
views
    standard codeigniter

A closer look at my (LOCAL) application folders (EACH SITE HAS ITS OWN):

Code:
cache
    symbolic link to parent
config
    symbolic link to parent
configs
    symbolic link to parent
controllers
    ALL LOCAL SITE SPECIFIC CONTROLLERS GO HERE
    default controller is index.php as set in CI's global config
errors
    symbolic link to parent
helpers
    symbolic link to parent
hooks
    symbolic link to parent
libraries
    symbolic link to parent
models
    symbolic link to parent
templates
    symbolic link to parent
templates_c
    symbolic link to parent
views
    symbolic link to parent

A closer look at my individual site's ROOT folders

Code:
.htaccess
    (see below)
index.php
    links to (local) application folder and global system folder
    system folder can be changed in one place to reference a new CI install
applications
    mostly contains symbolic links, but has a legit controllers folder

A closer look at my sites individual .htaccess files:

Code:
Options +SymLinksIfOwnerMatch
    
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond $1 !^(index\.php|common|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>


TWEAKAGE:

A few small edits I made along the way.

For SSL.

Since I have a single CI config file for multiple applications/sites I had to make a small change to the way the $config[base_url] was captured. It now prefixes the URL with the proper protocol if SSL is in use on that site.

Code:
$config['base_url']    = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['HTTP_HOST']."/";

instead of

Code:
$config['base_url']    = "http://".$_SERVER['HTTP_HOST']."/";

For Smarty.

In my (global) applications autoload.php file, I add the following:

Code:
$autoload['libraries'] = array('mySmarty');

Then I create a class file in my (global) application/libraries folder (remember to edit the smarty path)

Found on the CI forums, thx to the author whoever you are!

Code:
if (!defined('APPPATH')) exit('No direct script access allowed');

require_once(APPPATH . "../../Smarty_2.6.18/libs/Smarty.class.php");

/*
|==========================================================
| Code Igniter - by pMachine
|----------------------------------------------------------
| www.codeignitor.com
|----------------------------------------------------------
| Copyright (c) 2006, pMachine, Inc.
|----------------------------------------------------------
| This library is licensed under an open source agreement:
| www.codeignitor.com/docs/license.html
|----------------------------------------------------------
| File: libraries/Smarty.php
|----------------------------------------------------------
| Purpose: Wrapper for Smarty Templates
|==========================================================
*/

class MySmarty extends Smarty{

    var $smarty;
    
    function MySmarty()
    {
        $this->smarty = new Smarty();
        $this->smarty->template_dir = APPPATH . "templates";
        $this->smarty->compile_dir = APPPATH . "templates_c";
        $this->smarty->cache_dir = APPPATH . "cache";
        $this->smarty->config_dir = APPPATH . "configs";
        $this->smarty->compile_check = true;
        $this->smarty->debugging = true;
        log_message('debug', "Smarty Class Initialized");
    }
    
    function assign($key,$value)
    {
        $this->smarty->assign($key,$value);
    }
    
    function display($template)
    {
        $this->smarty->display($template);
    }

}

I hope this is helpful for some, I appreciated having the forums as a resource to gather information from. CodeIgniter has a great community here.

Peace. Smile


Messages In This Thread
multiple sites, 1 codebase, using symlinks (with smarty) - by El Forum - 07-14-2007, 12:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB