Welcome Guest, Not a member yet? Register   Sign In
What would be the best way to go about making a CMS?
#1

[eluser]chobo[/eluser]
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.
#2

[eluser]chobo[/eluser]
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
#3

[eluser]esra[/eluser]
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.

Quote: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:

Quote: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:

Quote: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.
#4

[eluser]chobo[/eluser]
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!
#5

[eluser]gunter[/eluser]
for your first question you should take a look at Routing

Quote:$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.
#6

[eluser]chobo[/eluser]
I'm not sure if routing is the way to go for this one, it just doesn't feel right...
#7

[eluser]gunter[/eluser]
donĀ“t feel quilty if you are using the routing class :-)
(I never used it, but if it works, and there is no other way - why not...)
#8

[eluser]esra[/eluser]
[quote author="chobo" date="1187479153"]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.[/quote]

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.

[quote author="chobo" date="1187479153"]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.[/quote]

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.

[quote author="chobo" date="1187479153"]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.
[/quote]

My .htaccess for the site is as follows:

Code:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(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.
#9

[eluser]chobo[/eluser]
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
#10

[eluser]Skinnpenal[/eluser]
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.?




Theme © iAndrew 2016 - Forum software by © MyBB