Multiple Websites With The Same (Single) Back-End.

Hello all,

I was bit little confused about starting a new project which is Multiple websites with the same back-end.

We have let say 9 different sites (Yii) and a main site with Backend.I have to manage all the 9 sited with that single Backend.

Can you expert guys suggest me the best approach to do this by using this awesome framework (Yii).

The admin will login to admin area in the backend and manage all the 9 sites.If this can be done in Yii?

Thanks in Advance.

Hi,

I think there is no problem in doing this.

But I fear that if the 9 sites have greatly different content it becomes a huge Backend. It has the same extend as if you build 9 different backends.

If it is 9 times the same website but for different clients, your project should be a nice solution to administrate all client versions.

(My English is bad I know ^^)

Then what should be in the database.If i could make a master database having 9 sites db names which passes a Master id to the master admin by which that child db data is managed.

How can i implement the 9 domains to land on a single Admin.The most important part of this project.

Issues arrises are Parked domains technology.

I parked 3 domains and pointing to same web folder (Where is Yii).

In the Index file. made changes to conditional config file.


$hostname = $_SERVER['SERVER_NAME'];

switch (strtolower($hostname)) {

    case 'abc.com';

    case 'www.abc.com';

        $config = dirname(__FILE__) . '/protected/config/abc.php';

        // database 1

        break;

    case 'master.com';

    case 'www.master.com';

        $config = dirname(__FILE__) . '/protected/config/master.php';

        // database 2

        break;

    case 'xyz.com';

    case 'www.xyz.com';

        $config = dirname(__FILE__) . '/protected/config/xyz.php';

        // database 3

        break;

 default:

        $config = dirname(__FILE__) . '/protected/config/master.php';

}




made 3 more config file.

In the master config i used 3 db connections:


'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=db',

                        'emulatePrepare' => true,

			'username' => 'xxx',

			'password' => 'xxx',

			'charset' => 'utf8',

		),

                'db2'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=db2',

                         'class'=>'CDbConnection',

			'emulatePrepare' => true,

			'username' => 'xxx',

			'password' => 'xxx',

			'charset' => 'utf8',

		),

		'db3'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=db3',

                        'class'=>'CDbConnection',

			'emulatePrepare' => true,

			'username' => 'xxx',

			'password' => 'xxx',

			'charset' => 'utf8',

		),

And for data models i used Gustavo’s Extension Multiactive Record

Now the final part is how can i make a model which is point to a table(table exist in all 3 db’s) dynamically.

For example: i have a controller in master site to controll other site users data i call siteEdit action which list all the 3 other sites in a grid.

i call the sites user edit button then it call the relevant site’s user grid view,How can i achieve this,Currently its only calling that table which is mentioned in connectionId db but not dynamically changed.

Hi

Best Way is You can create the 9 different module and one is admin so total 10 module when user login then after you can call the whatever module.

I think it’s should be Help.

Ankit bhai: the main issue behind is tha i have a user table in all sites containing same fields.i create a model User,with the connectionId.what if i called the model data it generates data correctly but i want dynamic model instance creation according to choosing which site user i have to edit or view.

Hi

it’s login is same or not to all sites?

there is a seperate admin login who manage all the sites db dynamically.The admin select the site to edit, and then it can perform the CRUD operation for that site.That is the re usability of a model by maultiple db tables but its not achieved yet.

Hi,

so u can define one role for every site so if role is login u can manage the CRUD but one thing is your user table field same to all site so u can add more field user_type and user_role so easily u can manage to access all data in one admin

main problem is the one model with 9 db’s users table.suppose i use $model= new User; what db table it should select is based connectionId which is in the User model. how can it be made dynamically so that i can initialize a model to a particular user table also with a particular db.

Hi

In your registration page u must one drop-down field (9 records) and select dropdown value in insert the user_type filed in user table