首页 文章

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

提问于
浏览
4

我想让我的网络应用程序主题化 . 我研究了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

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

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

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

    当你需要调用管理员模板时,你会打电话给:

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

相关问题