GSto
GSto

Reputation: 42350

How to add custom code to the 'system' folder of CodeIgniter?

I am looking into building my own CMS / extended framework on top of CodeIgniter, and I was wondering how to structure it to keep code out of the application folder. I noticed that in a typical CI set up, the file structure looks like this:

application/    //code for your application
system/         //CodeIgniter core
index.php

However, in PyroCMS, They have used the following structure:

application/    //code for your application 
system/
--cms/          //PyroCMS core
--codeigniter/  //CodeIgniter core.

How do I accomplish a similar result?

Upvotes: 0

Views: 720

Answers (3)

SwiftD
SwiftD

Reputation: 6069

The short answer is that everything starts from index.php, this is where core/CodeIgniter.php is included and it is also where application and system paths are set (retrieving values from config).

I think that pyro cms actually sets /system/cms as the application folder, presumably they have written code which looks at the presented application folder for content and processes it.

Another approach is to use wiredesigns modular HMVC:

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

This will allow you to separate your code out into modules. Just have a folder called cms containing all your cms modules and another folder to build your custom content on top.

You set the path to your modules folder in the config so if you wanted your cms code in the system folder you could set the path to your modules folder there and build on top using codeigniter in the standard way, perhaps adding a hook before or after your controller is loaded to call the cms core.

Upvotes: 1

Christian Giupponi
Christian Giupponi

Reputation: 7618

Mine is just a suggestion but you can easy fork pyrocms and build your own cms on it. PyroCMS will deprecate codeigniter in the next version so you can keep their code and fix it where you need and modify it as you want

Upvotes: 0

manix
manix

Reputation: 14747

To emulate that structure just edit the index.php constants:

  • APPPATH
  • BASEPATH

@WebweaverD has provide you a good solution to improve your application usgin HMVC. I will give you another.

How about something like this:

-system/      //CI core
-index.php      //manage the front_end requests
-acp.php      //manage the back_end requests
-apps/      //applications dir
--back_end/      //only "admin" controllers, libraries, config. No views here
--frond_end/      //only "user" controllers, libraries, config. No views here
--acp/      //views for back_end
--themes/      //views for front_end

All above can be implemented as you want only extending the necessary core files.

Upvotes: 1

Related Questions