Re: How to set up site structure with Admin folder and controllers?
HAH. Turned out that this was much easier than I thought. The correct terminology to search for was "Admin Routing" and "Prefix Routing". http://book.cakephp.org/view/544/Prefix-Routing Thanks guys! Leo --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to set up site structure with Admin folder and controllers?
The bakery and manual already talk extensively to admin routing, and they really could not make it simpler. I suggest you dig into the manual, and come back with a more focused question about this. On Feb 25, 1:48 pm, brian wrote: > On Wed, Feb 25, 2009 at 10:20 AM, Adam Royle wrote: > > > Have you looked into admin routing? > > > You'll just need to prefix your actions and your views with "admin_" to get > > it to work (and enable it in app/core.php) > > > And then set up a route for your admin homepage, which would point to > > AdministratorsController::admin_dashboard() > > > Router::connect('/admin', array('controller' => 'administrators', 'action' > > => 'dashboard', 'admin' => 'admin')); > > I agree that it's not really clear how best to do this. The way I > settled on was to load the admin_index views for each of the other > models into my Administrator's admin_index view using jquery's > UI.tabs. I'll run down the basic steps I took. > > Create admin_index() actions in each of the models,along with > corresponding views. > > Create an admin.ctp layout. > > Create an admin_nav.ctp element to include in the admin layout. > > Set up the nav to have links to each of the other models' admin_index actions: > > > site > > > link( > 'members', > array( > 'controller' => 'members', > 'action' => 'index', > 'admin' => 1 > ), > array( > 'id' => 'admin_members', > 'title' => 'members administration' > ) > ); > ?> > > > link( > 'posts', > array( > 'controller' => 'posts', > 'action' => 'index', > 'admin' => 1 > ), > array( > 'id' => 'admin_posts', > 'title' => 'posts administration' > ) > ); > ?> > > Tell jquery you want the above list tabbified: > $('#nav_admin ul').tabs({your options here}); > > The way tabs work is that, if the href is an external page, it can > load that using ajax. The 1st tab is loaded on default. Thus, my > AdministratorsController::admin_index() is empty. Each of the > admin_index actions for the other models fetches whatever data is > needed and their views displayit as required. > > The Administrator's admin_index view looks like: > > > > ... etc. > > The ajax content for each tab's URL is loaded into the appropriate div > using the title attribute of the link. This also means that I can > target a particular tab from elsewhere. Say you have a list of > Stories in that model's admin_index view, with a link to edit each. > From the StoriesController's admin_edit action, you can redirect like > so: > > $this->flash( > 'The Story has been saved', > array( > 'controller' => 'administrators', > 'action'=>'index', > '#' => 'stories_administration', > 'admin' => 1 > ) > ); > > If you've set up the tab link with 'title' => 'stories administration' > and have a div with ID stories_administration, this will force jquery > to load the Story tab. > > There were a few bumps in the road so, if you go with this idea, feel > free to ask for more detail. This particular post has run long enough. > > hmmm Bakery article? --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to set up site structure with Admin folder and controllers?
On Wed, Feb 25, 2009 at 10:20 AM, Adam Royle wrote: > > Have you looked into admin routing? > > You'll just need to prefix your actions and your views with "admin_" to get > it to work (and enable it in app/core.php) > > And then set up a route for your admin homepage, which would point to > AdministratorsController::admin_dashboard() > > Router::connect('/admin', array('controller' => 'administrators', 'action' > => 'dashboard', 'admin' => 'admin')); > I agree that it's not really clear how best to do this. The way I settled on was to load the admin_index views for each of the other models into my Administrator's admin_index view using jquery's UI.tabs. I'll run down the basic steps I took. Create admin_index() actions in each of the models,along with corresponding views. Create an admin.ctp layout. Create an admin_nav.ctp element to include in the admin layout. Set up the nav to have links to each of the other models' admin_index actions: site link( 'members', array( 'controller' => 'members', 'action' => 'index', 'admin' => 1 ), array( 'id' => 'admin_members', 'title' => 'members administration' ) ); ?> link( 'posts', array( 'controller' => 'posts', 'action' => 'index', 'admin' => 1 ), array( 'id' => 'admin_posts', 'title' => 'posts administration' ) ); ?> Tell jquery you want the above list tabbified: $('#nav_admin ul').tabs({your options here}); The way tabs work is that, if the href is an external page, it can load that using ajax. The 1st tab is loaded on default. Thus, my AdministratorsController::admin_index() is empty. Each of the admin_index actions for the other models fetches whatever data is needed and their views displayit as required. The Administrator's admin_index view looks like: ... etc. The ajax content for each tab's URL is loaded into the appropriate div using the title attribute of the link. This also means that I can target a particular tab from elsewhere. Say you have a list of Stories in that model's admin_index view, with a link to edit each. >From the StoriesController's admin_edit action, you can redirect like so: $this->flash( 'The Story has been saved', array( 'controller' => 'administrators', 'action'=>'index', '#' => 'stories_administration', 'admin' => 1 ) ); If you've set up the tab link with 'title' => 'stories administration' and have a div with ID stories_administration, this will force jquery to load the Story tab. There were a few bumps in the road so, if you go with this idea, feel free to ask for more detail. This particular post has run long enough. hmmm Bakery article? --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to set up site structure with Admin folder and controllers?
Have you looked into admin routing? You'll just need to prefix your actions and your views with "admin_" to get it to work (and enable it in app/core.php) And then set up a route for your admin homepage, which would point to AdministratorsController::admin_dashboard() Router::connect('/admin', array('controller' => 'administrators', 'action' => 'dashboard', 'admin' => 'admin')); Hope that helps, Adam - Original Message - From: "Leonard Teo" To: "CakePHP" Sent: Thursday, February 26, 2009 12:25 AM Subject: How to set up site structure with Admin folder and controllers? > > Hi, > > I'm an experienced PHP developer that's just started using Cake. > Apologies in advance if this is a n00bish question. > > > I've created several models, controllers and scaffolds but I would > like them all to reside in a /admin folder in the site structure. > > > E.g. Models > - Administrator > - Story > - File > > > The default cake site structure is this: > root/administrators > root/stories > root/files > > How do I set Cake up so that all the above go into a backend > directory? > > E.g: > > root/admin/administrators > root/admin/stories > root/admin/files > > > I would also like to create an admin controller so that the homepage > for admin will show a dashboard: > e.g. > root/admin/. will show a backend dashboard. > > > I've been generally good at finding my way around but was unable to > find information on doing this - If anyone could help point me in the > right direction, that'd be great. > > Thanks!! :) > > Leo > > > > > > --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---