Sunday, December 28, 2008

Re: Newby: Basic file structure for website & CMS

Have a look at prefix routing:
http://book.cakephp.org/view/544/Prefix-Routing
What you'll end up with is, for example:
config/core.php
// enable admin routing
Configure::write('Routing.admin','admin');

controllers/news_controller.php
NewsController {
function index() {
// this is public
}
function view() {
// also public
}
function admin_add() {
// private
}
function admin_edit() {
// also private
}
}
And your views/news directory would have:
views/news/index.ctp
views/news/view.ctp
views/news/admin_add.ctp
views/news/admin_edit.ctp

The resulting urls for these actions are:
http://example.com/myapp/news/ (index action maps to / by default)
http://example.com/myapp/news/view/some_id
http://example.com/myapp/admin/news/add
http://example.com/myapp/admin/news/edit/some_id

All you need now is some sort of authentication and authorization
mechanism to protect your admin actions.


danwednesday wrote:
> Hi,
>
> I'm brand new to php and the MVC style of development. I've read some
> of the cakephp documentation and it makes sense in theory, so I'm keen
> to push on. However, the first task I've set myself is to build a
> simple website and CMS for displaying and administering news
> articles. I have built the back-end (CMS) based on the same blog
> application in the cakephp documentation, but my problem is I don't
> know how to deal with the file structure to make the CMS files
> distinct from the website files.
>
> What I want to do is have my website files so they're accessible in
> the domain root. e.g. http://www.example.com/latest_news_articles and
> http://www.example.com/articles/my_first_article. I want the CMS
> files though to appear within an 'admin' folder, e.g.http://
> www.example.com/admin/add_news_article and http://www.example.com/admin/edit_news_article.
>
> Do I put all models/views/controllers in the same files in the app
> folder, or do I create directories in the app folder and have lots of
> different model/view/controller files?
>
> Thanks folks!
>
> >
>
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: