Building a CMS to For Website Building a CMS to For Website codeigniter codeigniter

Building a CMS to For Website


The basic structure of Codeigniter is that you have 2 folders and 1 file in your root folder:

root/application/root/system/root/index.php

Now, obviously, you might have many more files and folders in there as well, but these are the basics upon which every Codeigniter app runs.

What do each of these do? To begin with, every page request starts at index.php. This page set's up some configurations and some constants, and then hands over the reigns to Codeigniter.

Where is "Codeigniter" located? That would be the system folder. This folder should never be touched, by you or anyone else. Everything pertaining to your app is stored within the application folder. This includes all your configurations, your controllers, your models, your views, even your library extensions (although you could store other stuff outside this folder, like images/css/js/fonts etc.).

So, the correct way to set up shop would be:

root/application/root/system/root/index.phproot/kowmanager/applicationroot/kowmanager/index.php

But, you have to inform your kowmanager's index.php that the system folder is not located in the same directory. So, within the index.php (inside of kowmanager), at around line 25, you should see this:

$system_path = "system";

Simply change it to:

$system_path = "../system";

and you're done.

Now both your apps (your main site and you CMS) will be sharing the same Codeigniter base. When the time comes to update CI, you'll do that once within the main system folder...


I've done several Codeigniter CMS's and taken both routes:

  • Integrated (shared application files and assets)
  • Separate installation (only shared system files, if any)

At first I liked the convenience of the integrated approach: when I needed a custom library or icon file for the front and back end, it was available without duplication. I've since changed my mind.

My opinion now, after 4 years or so of working on these, is that the benefits of having an integrated CMS is short-lived.

  • 90% of the code is in the back end, so you end up with lots of helpers, libraries, etc. that are only used for administration.
  • Any shared resources that you need to tweak can end up working great on one side, but breaking the other, or being overkill/useless.
  • Models tend to be bloated for use on the front-end when they are full of code that's only used for the back end.
  • Shared templates, js, and css files almost never work. The control panel probably doesn't need to work in IE{insert version here}, but your front end should.
  • It makes updates and upgrades to either end sketchy, unless you know exactly what you need to update and what not to touch, and where you may have made customizations for a particular site's front end that should not be altered.
  • Auth logic is much easier when your admins and regular users aren't in the same bucket
  • Separate installations are easier to set up, and they can be "tacked on" to an existing site rather than having to integrate it.

My advice: Go with a separate installation.


If I were you, I would probably not go the separate applications path. If you're sharing things like code that renders a page or logs a user in, you'll be repeating it for both installs. Obviously two separate installs would only require one system folder of which you'd share as nothing changes in system. If it were me, I'd probably just set up a route in your config/routes.php file.

Something like the following (presuming you have a controller called 'kowmanager' inside a folder called 'kowmanager' in your controllers folder):

// This would redirect all calls to kansasoutlawwrestling.com/kowmanager // to the kowmanager controller.  $route['kowmanager'] = "kowmanager/kowmanager";// Redirects all kowmanager/method requests to the kowmanager folder// and a particular controller$route['kowmanager/(:any)'] = "kowmanager/$1";// Redirects all kowmanager/method requests to the kowmanager folder and a// particular controller and method inside controller.$route['kowmanager/(:any)/(:any)'] = "kowmanager/$1/$2";

Might not be the best option, but it means you won't repeat the same code twice and you've essentially created two applications inside one. There are numerous other ways of doing this including some rewrites in your .htaccess file.

If you want the easier option, go separate installs and be mindful of code repetition. Stick to the DRY (Don't Repeat Yourself) methodology.