How do you organize your template structure in CodeIgniter?

后端 未结 3 1422
野趣味
野趣味 2021-02-06 04:44

I will be building a CMS for my final Web Development course project, and i\'ve been challenged by my teacher creating it in an MVC system, and for now, I\'ll be using CodeIgnit

相关标签:
3条回答
  • 2021-02-06 04:56

    I am totally agreed with web-johnny file folder structure but in my opinion he missed one thing define all your assets path in ./application/config/constants.php file e.g.

    define('IMAGES_PATH', your_absolute_path_of_images_folder);
    define('CSS_PATH', your_absolute_path_of_css_folder);
    define('SCRIPTS_PATH', your_absolute_path_of_scripts_folder);
    

    and so on... use these constants throughout the application so in this way if you ever need to change your file folder structure you just need to change the values of these constants.

    0 讨论(0)
  • 2021-02-06 05:18

    A good file/folder structure would be the below:

    website_folder/
    –––– application/
    –––––––– config/
    –––––––––––– autoload.php
    –––––––––––– config.php
    –––––––––––– ...
    –––––––– controllers/
    –––––––––––– examples.php
    –––––––––––– index.html
    –––––––––––– welcome.php
    –––––––– ...
    –––––––– views/
    ––––––––---- templates/
    ––––––––-------- backend.php
    ––––––––-------- frontend.php
    –––––––––––– ....
    –––––––––––– example.php
    –––––––––––– index.html
    –––––––––––– welcome_message.php    
    –––– assets/
    –––––––– css/
    –––––––– js/
    –––––––– images/
    –––––––– templates/
    ––––––––---- frontend/
    ––––––––-------- css/
    ––––––––-------- js/
    ––––––––-------- images/
    ––––––––---- backend/   
    ––––––––-------- css/
    ––––––––-------- js/
    ––––––––-------- images/
    –––––––– uploads/
    –––––––– index.html
    –––– system/
    –––– user_guide/
    –––– index.php
    –––– license.txt 
    

    This is just a suggestion. So you will have your template views at views/templates and your css/js files at assets/templates/

    0 讨论(0)
  • 2021-02-06 05:20

    Check the Modular Extensions HMVC, it's really useful when your project starts to grow. Modular Extensions - HMVC makes the CodeIgniter PHP framework modular. Modules are groups of independent components (typically, controller, model and view) arranged in one application sub-directory that can be dropped into other CodeIgniter applications.

    0 讨论(0)
提交回复
热议问题