Welcome Guest, Not a member yet? Register   Sign In
CMS Application structure
#1

[eluser]freshface[/eluser]
As the title says, how would you structure your code and handle an advanced cms in CI.

How I would do it:

There will be a public frontend (the website) and the backend (admin part).
So i would have 2 applications running on one CI system.

For the backend i would work with modules (HMVC).
Module folder structure (ex. blog)

-Blog
-- module_settings.php // contains some config settings like (is $is_in_main_nav = TRUE/FALSE)
-- Controllers // this wil contain the code for posting, editting, deleting, ..
-- Models // Models to handle the queries
-- View // Views
-- Languages // translations for the module
-- Routes // If the blog module needs a custom route
-- Settings // There will be settings for this module (like trackbacks, allow comments, advanced markup, ...)


Each module will have the same structure (maybe it could be better?)

When I go to site.com/backend/modules/blog the blog module would need to show up.
When I go to site.com/backend/settings/blog i should see the settings.


But I am curious on your approach and you would handle something like this.
Keep in mind that something like this needs to be clear and easy modify-able and flexable.

This is for the backend part.
#2

[eluser]Phil Sturgeon[/eluser]
I use Matchbox for my CMS but its the same idea.

Modules each have an admin controller (if not they don't show up on my admin navigation tabs) and have all their views in an admin sub-folder. There is no need for front/back separation as they all use the same data.

Quote:- modules

—- blog
—-- controllers
——-- admin.php
——-- blog.php
—-- models
—-- views
---- admin
----- index.php
----- edit.php
---- index.php

—- comments
—-- controllers
——-- admin.php
——-- comments.php
—-- models
—-- views

- models
- views

This can be accessed via http://example.com/blogs
This can be accessed via http://example.com/admin/blogs
This can be accessed via http://example.com/admin/blogs/edit/1

To see how my routes work, check out the following post where I answered this before.

Post: matchbox and that old admin folder question
#3

[eluser]Phil Sturgeon[/eluser]
Oh, and to add routes to modules, check out my blog post on doing just that.

Matchbox with modular routes in CodeIgniter
#4

[eluser]freshface[/eluser]
Thx for the reply.
I always used HMVC( from wiredesign).

Why should I use Mathbox are there any advantages?
#5

[eluser]Phil Sturgeon[/eluser]
I use matchbox as it works for me. Have never tried HMVC so can't argue strengths or weaknesses of either. My modification to the router on that blog post can easily be modified to suit HMVC or any modular approach you like.

Let me know if you have trouble doing so.
#6

[eluser]freshface[/eluser]
What i do for routing is put a loop in routes.php in the config folder.
Like this:

Code:
$handle = opendir(APPPATH.'modules');

if ($handle)
{
    while ( false !== ($module = readdir($handle)) )
    {        
        if (substr($module, 0, 1) != ".")
        {
            if ( file_exists(APPPATH.'modules/'.$module.'/'.$module.'/routes/routes.php') )
            {
                include(APPPATH.'modules/'.$module.'/'.$module.'routes/routes.php');
            }
            
            $route[$module] = $module;
            $route[$module.'/(.*)'] = $module.'/$1';
        }
    }
}
#7

[eluser]Phil Sturgeon[/eluser]
Is a config file really the best place to put that? That is essentially what mine is doing, but in the Router it feels at home.

IF you must do it in the config file, try a neater 1-liner that does the same thing.

Code:
foreach(glob(APPPATH.'modules/*', GLOB_ONLYDIR) as $module) @include_once($module.'/config/routes.php');
#8

[eluser]freshface[/eluser]
Thx.
A config file is indeed not the correct place to do.
I 'stole' the idea from the blaze cms.

It has a nice approach.
#9

[eluser]tmkajk[/eluser]
[quote author="pyromaniac" date="1229536939"]I use Matchbox for my CMS but its the same idea.

Modules each have an admin controller (if not they don't show up on my admin navigation tabs) and have all their views in an admin sub-folder. There is no need for front/back separation as they all use the same data.[/quote]

@pyromaniac,
How are you auto generating your admin nav tags? Are you iterating through the module directories and looking for admin.php or does Matchbox have a moduleExists() function that I missed when browsing the source?


~ Todd




Theme © iAndrew 2016 - Forum software by © MyBB