On Wed, Feb 25, 2009 at 10:20 AM, Adam Royle <a...@sleekgeek.com.au> 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: <div id="nav_admin"> <h6><a href="/" title="main site">site</a></h6> <ul> <li> <?= $html->link( 'members', array( 'controller' => 'members', 'action' => 'index', 'admin' => 1 ), array( 'id' => 'admin_members', 'title' => 'members administration' ) ); ?></li> <li> <?= $html->link( 'posts', array( 'controller' => 'posts', 'action' => 'index', 'admin' => 1 ), array( 'id' => 'admin_posts', 'title' => 'posts administration' ) ); ?></li> 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: <div id="members_administration"></div> <div id="posts_administration"></div> ... 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 -~----------~----~----~----~------~----~------~--~---