Saturday, July 27, 2013

Re: One Core, One App, One Databsse, Multiple Domains & Multiple Themes

Cake has a great theme system which falls back on default views if a certain view is not present in the theme. What you are asking is definitely possible, I don't believe there is anything in the core that does exactly what you need but it wont take too much work to get it working. 


This is just something from the top of my head and have not tried it but i think you could just do something like the following in AppController.php

public function beforeRender(){
   if($_SERVER['SERVER_NAME'] == 'domain1'){
    $this->theme = "theme1";
   }
   else
   {
    $this->theme = "default";
   }

}


On Thursday, July 25, 2013 1:55:29 PM UTC+1, Elliot wrote:
Hello Everyone,

I am a new addition to the world of CakePHP, and have only created / followed the blog tutorial, and extended it with users. I have been reading the 2.0 book to become more familiar with the framework.

Before I commit to moving to CakePHP, I have a couple of questions.

Currently, I develop a multi domain / multi theme CMS system which is procedural PHP. By doing this I have been able to create a single system on a single database with multiple domains and themes.

I take the $_SERVER['SERVER_NAME'] and look it up in a table of "brands" and then return a brand_id and theme directory. I then suffix all my SQL queries with "and brand_id = X".

I am looking to move over to Cake as the current platform has become overwhelming in size and complexity.

So in short...

Can I create an application with One Core, One App, One Database that can serve Multiple Domains and Themes?

Would I use $_SERVER['SERVER_NAME'] to look up the domain and return back a brand_id and theme?

I don't really want to have multiple databases, as if we had a large number of customers making changes across all databases could prove time consuming.

I certainly don't want to have multiple controllers and multiple models, but in some cases we would want a bespoke view if a customer had a specific requirement.

Any guidance on a basic configuration to get me started would be great. Would each Model "belong to" a "brand"? How would you "serve" up a brand?

Name: Brand1 Domain: www.brand1.com ThemeDir: Brand1
Name: Brand2 Domain: www.brand2.com ThemeDir: Brand2

Thanks

Elliot


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: