After digging through the code and debugging. I did the following to
make the code work with multiple projects with project specific
layouts and views.

Defined a configuration array which contains settings for each project
group.config.php

<?php
    $application_config =
          array(
                         'project1.site.com' => array(
                              'db' => 'local_prj1',
                              'group_name' => 'Project1',
                              'group_title' => 'Project1,
                              'html_meta_description' => 'Metadata',
                              'rss_feed_url' => '/messages.rss',
                              'rss_feed_url_title' => 'Project 1 (Dev) RSS',
                              'analytics_tracking_code' => 'UA-99999'',
                              'webmaster_email' => '[EMAIL PROTECTED]',
                              'page_size' => 15,
                              'index_threshold' => 10
                              ),
                         'project2.site.com' => array(
                              'db' => 'local_prj2',
                              'group_name' => 'Project2',
                              'group_title' => 'Project2,
                              'html_meta_description' => 'Metadata',
                              'rss_feed_url' => '/messages.rss',
                              'rss_feed_url_title' => 'Project 2 RSS',
                              'analytics_tracking_code' => 'UA-99999'',
                              'webmaster_email' => '[EMAIL PROTECTED]',
                              'page_size' => 15,
                             'index_threshold' => 10
                             )
                );
?>

Implemented beforeFilter in project wide app_controller.php

    function beforeFilter() {
                
        parent::beforeFilter();
        $this->project = $_SERVER['SERVER_NAME'];

                require(APP.DS.'config'.DS.'groups-config.php');
                
        $project_settings = $application_config[$this->project];

        foreach($project_settings as $key => $value) {
                        $this->$key = $value; // object variables
                        $this->set($key, $value); //available for views as well
                }

        // common view
        $common_view_path = VIEWS."common" .DS;
        // group specific views
        $group_view_path = VIEWS.$this->group_name.DS;

        // group specific views takes precedence
        $viewPaths = array($group_view_path, $common_view_path);

        // common helper folder
        $common_helper_path = $common_view_path. 'helpers'.DS;
        // group helper folder
        $group_helper_path = $group_view_path.$this->group_name.'helpers'.DS;

        // group specific folder takes precedence
        $helperPaths = array($group_helper_path, $common_helper_path);

            $configure =& Configure::getInstance();
        // order of precedence group, common and general
            $configure->viewPaths = array_merge($viewPaths, 
$configure->viewPaths);
            $configure->helperPaths = array_merge($helperPaths,
$configure->helperPaths);
        // use plugin option to have project specific cache as well
            $this->set("scache",
               array('cache' => '+365 days', 'plugin' => $this->group_name));
    }
}

Implemented setDataSource method in app_model.php to set the database
name specific to projects

        function setDataSource($dataSource = null) {

                require(APP.DS.'config'.DS.'groups-config.php');
        $project = $_SERVER['SERVER_NAME'];
        $project_settings = $application_config[$project];
        $db_conn = $project_settings['db'];
                parent::setDataSource($db_conn);
        }

On 8/30/07, Humble Groups <[EMAIL PROTECTED]> wrote:
> All,
>
>   I have a requirement where I would like to have single
> codebase/project but maintain multiple clients. In this case I would
> like to have default for everything (views, layouts, webroot css, js,
> etc.,). But if there is anything specific to client, then I should be
> able to override.
>
>   I saw how to have same cakephp code, but different project code, but
> couldn't find anything on the above topic.
>
>   Was this discussed already?
>
>    Typically I would like to have a structure like this.
>
>    app/tmp/<client-specific>
>    app/webroot - css, js, sitemap.xml files, etc.,
>
>    app/views/<client-specific-folder> - High Precedence
>    app/views/default/
>
>    What are all the places/variables I have to modify to make this work?
>
>    How to I define the settings for each project using global
> variable? I tried bootstrap.php, didn't work. As of now, I have it in
> app_controller. It is actually an array of projects and their settings
> in sub array.
>
>   TIA
>
> Regards
> Humble
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to