EllisLab text mark
Advanced Search
     
What would be the best way to go about making a CMS?
Posted: 18 August 2007 03:00 AM   [ Ignore ]
Joined: 2007-07-18
92 posts

I’m not sure how to go about making a CMS for my site… Should I just make a new controller and create a CMS library. It just seems wrong to have all the files for the site mixed together with it… If I use a controller would it be easy to block access to it via .htaccess file? Any help is appreciated, thanks.

 Signature 

Check it out: Critique Computer Products

 
Posted: 18 August 2007 04:54 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-07-18
92 posts

I searched around and came up with a pretty decent solution, to save others time I’ll post it. I split my application folder into two sites, one is the main one everyone sees, the other is the admin/cms site, they both share the same system folder. I then made a new folder in my webroot (where the index.php front controller is) and made a copy of the index.php and threw it in there, I also had to make another copy of my paths file and gave it a different name, it was just to specify the application path. I then added a .htaccess to that folder banning everyone but me, so there you have it smile

 Signature 

Check it out: Critique Computer Products

 
Posted: 18 August 2007 06:31 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2006-07-10
485 posts

There is a contribution called Modular Separation by Zawk. It allows your MVC triads (models, views, and controllers) to be stored in a directory structure like a CMS. You need to read the forum thread referenced in the wiki article for additional changes contributed by others.

modules/
modules/modulename1/controllers/
modules/modulename1/language/
modules/modulename1/models/
modules/modulename1/views/
modules/modulename2/controllers/
modules/modulename2/language/
modules/modulename2/models/
modules/modulename2/views/
...

With some additional changes mentioned in the forum thread, you can also do something like this to store reusable view fragments embedded in your master views or templates:

blocks/
blocks/related_content/
blocks/popular_content/
blocks/random_content/
blocks/login/
blocks/menu/
...

And for master views or templates, you can store them in a separate directory structure which is useful if you need multiple master views (templates) or want to support template switching:

templates/
templates/templatename1/index.php
templates/templatename1/css/
templates/templatename1/js/
templates/templatename1/images/
templates/templatename2/index.php
templates/templatename2/css/
templates/templatename2/js/
templates/templatename2/images/
...

The Modular Separation contribution and Coolfactor’s Proposed View Library X3 work great together, making it possible to create a CMS-like infrastructure.

 
Posted: 18 August 2007 03:19 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2007-07-18
92 posts

That modular separation seems like a really good way to organize code, so I’m all for it smile I would also like to try templating since I still have design issues with dealing partial or fragment views that depend on a few wrapper div tags that complete the layout, I just don’t know where to put them. I don’t want the in the partials because they make them less resuable, and they don’t work well in default areas. For now I’m going to focus on modular separation, I just have a few questions.

Q. If I just have two modules say for example my main site code and the admin cms, how would I access my main site with the same url’s as I am now (without specifying the modulename every time). I’m not too clear on how it handles that aspect of it. 

Q. What would you suggest as being a good way to handle user authentication. Currently, I just use an .htaccess denying everyones IP, except my own, which was alright. If I use modular separation as far as I know I can’t use that .htaccess solution anymore

Thanks!

 Signature 

Check it out: Critique Computer Products

 
Posted: 18 August 2007 04:10 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-27
198 posts

for your first question you should take a look at Routing

$route[‘product/:any’] = “catalog/product_lookup”;
Any URL with “product” as the first segment, and anything in the second will be remapped to the “catalog” class and the “product_lookup” method.

 
Posted: 18 August 2007 05:29 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2007-07-18
92 posts

I’m not sure if routing is the way to go for this one, it just doesn’t feel right…

 Signature 

Check it out: Critique Computer Products

 
Posted: 18 August 2007 06:20 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-27
198 posts

don“t feel quilty if you are using the routing class grin
(I never used it, but if it works, and there is no other way - why not…)

 
Posted: 18 August 2007 09:28 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Joined: 2006-07-10
485 posts
chobo - 18 August 2007 07:19 PM

That modular separation seems like a really good way to organize code, so I’m all for it smile I would also like to try templating since I still have design issues with dealing partial or fragment views that depend on a few wrapper div tags that complete the layout, I just don’t know where to put them. I don’t want the in the partials because they make them less resuable, and they don’t work well in default areas. For now I’m going to focus on modular separation, I just have a few questions.

For initial testing purposes, you can take the default welcome application and convert it into a module, then copy the module folder multiple times, assigning a new name each time. Then rename the files for each module and change the code to reflect the name change. This allows you to shell out an entire application quickly. This will give you a basic platform for testing modular separation.

I started out originally with a light template library called bTemplate by Brian Lozier, but after listening to arguments here, I decided to use PHP views. Coolfactor’s view library was a godsend for what I’m doing. It’s also ideal for Web 2.0 layouts. It handles extremely complex master views very well. I use the EXT JS library in conjunction with CI as my basic framework. EXT JS layouts can be very complex. The best way to handle master views or templates is to think in terms of a master view divided into a main container subdivided into subcontainers (left column, right column, navigation, header, footer, etc.). Then you can embed your various view fragments in those subcontainers.

chobo - 18 August 2007 07:19 PM

Q. If I just have two modules say for example my main site code and the admin cms, how would I access my main site with the same url’s as I am now (without specifying the modulename every time). I’m not too clear on how it handles that aspect of it.

I have two applications under the applications/ folder—one called main (the site) and the other called admin. I make a copy of index.php and rename it to admin.php, then include admin.php in my urls to call the admin application. Others have developed some creative ways of handling admin within a single application directory structure. Using my approach, it’s also possible to place an admin directory under a single application (basically, another application within your site application. For larger sites where subdomains are required, I embed a iframe in my Admin template and load the default admin module for the domain and subdomains. This gives me a single entry point for all admin modules among a family of sites.

chobo - 18 August 2007 07:19 PM

Q. What would you suggest as being a good way to handle user authentication. Currently, I just use an .htaccess denying everyones IP, except my own, which was alright. If I use modular separation as far as I know I can’t use that .htaccess solution anymore.

My .htaccess for the site is as follows:

Options +FollowSymLinks
Options 
-Indexes
DirectoryIndex index
.php
RewriteEngine on
RewriteCond 
$!^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.*)$ index.php/$1 [L,QSA] 

FreakAuth and UserAuth (extracted from Derek Allard’s miniapp application) can be converted to modules. I’m using a fine-grained RBAC solution that has not been released to the wiki yet (still needs some time to work out the kinks). From other posts, I understand that the Zend Framework’s ACL library works well with CI.

 
Posted: 18 August 2007 11:45 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Joined: 2007-07-18
92 posts

Thanks for the sharing that information, it was very informative. For now I’m going to finish the backend using my current method and when my new version of the site is up (1 or 2 days smile), I’ll have more time to look into modular separation library and cool factors template library.

Just when you start to think you know something about CodeIgniter, you find out about more classes to make live easier; I love it… smile

 Signature 

Check it out: Critique Computer Products

 
Posted: 01 September 2007 10:15 AM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2007-09-01
44 posts

I’m just wondering, how do one go about making the View library work like described in the post above, with the template paths etc.?

 
Posted: 01 September 2007 03:26 PM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Joined: 2006-07-10
485 posts

The solution mentioned above is documented in the Modular Sepration thread and elsewhere on the forums. It requires some changes to the view method of the MY_Loader extension included with Modular Separation version 2.0. Additional search paths were added to MY_Loader in order to support templates and blocks. Because of the way the View library is designed, no changes were required to use the View library with Modular Separation 2.0. Version 2.0 may still be available on the wiki.

Zacharias (formerly Zawk) posted Modular Separation version 3.0 a few days ago. The new version of Modular Separation includes four new methods—two in MY_Router.php and two in MY_Loader.php. The View library probably needs to be subclassed and methods need to be overloaded to support at least one of the new methods (module_view) added to the MY_Loader extension.