Code Igniter中主题文件夹结构的最佳方式?

时间:2012-03-06 04:34:59

标签: codeigniter themes

我想让我的网络应用能够主题化。我研究了3种方法:

解决方案1:

- application
    - views
        - theme1
            - template files
        - theme2
            - template files
        - admin template
- css
    - theme1
    - theme2
- js
    - theme1
    - theme2
- images
    - theme1
    - theme2

运作良好。但是,将文件放在单独的文件夹中时会感到不舒服。

解决方案2

- application
    - views
        - theme1
            - css
            - js
            - images
            - template files
        - theme2
            - css
            - js
            - images
            - template files
        - admin template

我将/application/.htaccess更改为

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]  

它也运行良好,但对安全性有好处吗? (我不擅长.htaccess)

解决方案3

- application
    - views
        - admin template
- themes
    - theme1
        - css
        - js
        - images
        - template files
    - theme2
        - css
        - js
        - images
        - template files

我在MY_Loader中将视图路径更改为主题文件夹。

看起来更好的结构。我的管理模板有问题。 但是我还想将管理模板文件放在文件夹视图中作为核心系统, 我不知道如何使视图加载功能可以在两个地方看到文件。

请大家为我提供最好的解决方案。 谢谢和最诚挚的问候,

1 个答案:

答案 0 :(得分:0)

在MY_Loader中,我假设你扩展了view()函数以在不同的位置寻找正确的视图?如果是这种情况,为什么不在MY_Loader中创建一个名为adminView()的新函数,或者只是view()函数的副本,但它会在管理位置查找视图。

在控制器中,调用主题特定文件的方法,您可以调用:

$this->load->view('template');

当您需要呼叫管理员模板时,您可以致电:

$this->load->adminView('template);