2

我是 CakePHP 世界的新成员,只创建/遵循博客教程,并与用户一起扩展它。我一直在阅读 2.0 的书以更加熟悉该框架。

在我承诺转向 CakePHP 之前,我有几个问题。

目前,我开发了一个多域/多主题的 CMS 系统,它是程序 PHP。通过这样做,我能够在具有多个域和主题的单个数据库上创建单个系统。

我拿起$_SERVER['SERVER_NAME']并在“品牌”表中查找它,然后返回一个brand_id和主题目录。然后,我在所有 SQL 查询后加上“and brand_id = X”。

由于当前平台的规模和复杂性已经变得不堪重负,我希望转向 Cake。

所以简而言之...

我可以创建一个可以服务多个域和主题的应用程序吗?

我会使用$_SERVER['SERVER_NAME']查找域并返回brand_id 和主题吗?

我真的不想拥有多个数据库,就好像我们有大量客户对所有数据库进行更改可能会很耗时。

我当然不想拥有多个控制器和多个模型,但在某些情况下,如果客户有特定要求,我们会想要定制视图。

任何让我入门的基本配置指导都会很棒。每个模型会“属于”一个“品牌”吗?你将如何“服务”一个品牌?

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

1 回答 1

1

I have a similar situation in which I am using wildcard subdomains. I accomplished this by doing a combination of things.

  1. In my bootstrap file I am reading in my subdomain and assigning it a value to the cakePHP cache. In my case I am calling:

    Configure::write('SubdomainHTTP', $myvalue);

This would be your domain name in your case.

  1. I am loading in my routes.php file a filename called subdomainRoute.php. This file checks to make sure that the route or subdomain in my case exists in the database. It concludes by writing the subdomain name and theme name using Configure::write like step 1.

    App::uses('SubdomainRoute', 'Routes');

  2. I glue it all together here, in my AppController.php I read the information I write in step 2. Specifically the theme name and set it using:

    $this->theme = $yourtheme;

This should allow you to have different domain name themes. Given you will have to have a database to hold a list of domain names and there theme names.

于 2013-07-26T17:38:32.960 回答