Re: Admin Routing Techniques
Hi Mariano, On 3/25/07, Mariano Iglesias <[EMAIL PROTECTED]> wrote: > > > Or even better, no parameter needed: > > function admin_add() > { > return $this->setAction('add'); > } > This works a treat, cheers. Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Admin Routing Techniques
Hi Guys, Thanks again for the further suggestions. @french13: Unless I'm not following what you are suggesting, I don't think you're following what I'm asking, (in which case I'm not surprised when I come out with sentences like this one :) I'm just looking for the best way to minimise code duplication while using Admin Routing. I'm not sure what you're suggesting above. It looks like you're suggesting a ControllersController for viewing actions. Could you elaborate? I'm just looking to use certain actions in an admin route without duplicating code. Cheers, Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Admin Routing Techniques
On Mar 27, 12:17 am, "fr3nch13" <[EMAIL PROTECTED]> wrote: > Ir Even better just bake it... if you can't bake it then: > > (i haven't played with 1.2 yet, but unless it was drastically changed > from 1.1.x, this is how you i do it:) > > change: > turn on admin routing, then:http://www.domain.com/admin/controller/action > > class ControllerController extends AppController > { > function admin_index() > { > $this->set('controller',$this->Model->findAll()); > } > function admin_action() > { > $this->checkSession(); // a function in the AppController, app/ > app_controller.php which checks the user is logged in and has > permissions FYI, I do not find checkSession anywhere in my 1.2. Looks like that need to Auth component instead, but I couldn't yet figured out it and it's doc. -- Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Admin Routing Techniques
Ir Even better just bake it... if you can't bake it then: (i haven't played with 1.2 yet, but unless it was drastically changed from 1.1.x, this is how you i do it:) change: turn on admin routing, then: http://www.domain.com/admin/controller/action class ControllerController extends AppController { function admin_index() { $this->set('controller',$this->Model->findAll()); } function admin_action() { $this->checkSession(); // a function in the AppController, app/ app_controller.php which checks the user is logged in and has permissions if(empty($this->data)) { } else { if($this->Model->save($this->data)) { $this->Session->setFlash('Model is saved'); $this->redirect('/admin/controller/index'); } } } } You shouldn't even have to call "this->render()" at all. Then you name your views: app/views/controller/admin_index.thtml app/views/controller/admin_action.thtml (replace thtml for ctp in 1.2) On Mar 25, 5:05 pm, "Mariano Iglesias" <[EMAIL PROTECTED]> wrote: > Or even better, no parameter needed: > > function admin_add() > { > return $this->setAction('add'); > > } > > function add() > { > if (isset($this->params[CAKE_ADMIN])) > { > $this->render('admin_add'); > } > > } > > -MI > > --- > > Remember, smart coders answer ten questions for every question they ask. > So be smart, be cool, and share your knowledge. > > BAKE ON! > > blog:http://www.MarianoIglesias.com.ar > > -----Mensaje original- > De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre > de Mariano Iglesias > Enviado el: Domingo, 25 de Marzo de 2007 05:53 p.m. > Para: cake-php@googlegroups.com > Asunto: RE: Admin Routing Techniques > > No, setAction() will set the $controller->action to 'add' and therefore > render() will render add.ctp > > But you can use a parameter: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Admin Routing Techniques
Or even better, no parameter needed: function admin_add() { return $this->setAction('add'); } function add() { if (isset($this->params[CAKE_ADMIN])) { $this->render('admin_add'); } } -MI --- Remember, smart coders answer ten questions for every question they ask. So be smart, be cool, and share your knowledge. BAKE ON! blog: http://www.MarianoIglesias.com.ar -Mensaje original- De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre de Mariano Iglesias Enviado el: Domingo, 25 de Marzo de 2007 05:53 p.m. Para: cake-php@googlegroups.com Asunto: RE: Admin Routing Techniques No, setAction() will set the $controller->action to 'add' and therefore render() will render add.ctp But you can use a parameter: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Admin Routing Techniques
No, setAction() will set the $controller->action to 'add' and therefore render() will render add.ctp But you can use a parameter: function admin_add() { return $this->setAction('add', true); } function add($admin = false) { if ($admin) { $this->render('admin_add'); } } -MI --- Remember, smart coders answer ten questions for every question they ask. So be smart, be cool, and share your knowledge. BAKE ON! blog: http://www.MarianoIglesias.com.ar De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre de Sonic Baker Enviado el: Domingo, 25 de Marzo de 2007 05:19 p.m. Para: cake-php@googlegroups.com Asunto: Re: Admin Routing Techniques Just wondering if setAction() allows rendering of a different view after the call? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Admin Routing Techniques
Thanks for all the replies people, On 3/25/07, Mariano Iglesias <[EMAIL PROTECTED]> wrote: > > > Instead do: > > function admin_add() > { > return $this->setAction('add'); > } > Just wondering if setAction() allows rendering of a different view after the call? Like: function admin_add() { return $this->setAction('add'); $this->render('admin_add'); } Cheers, Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Admin Routing Techniques
This is wrong: function admin_add() { $this->requestAction($this->viewPath . '/add); $this->render('admin_add'); } Instead do: function admin_add() { return $this->setAction('add'); } -MI --- Remember, smart coders answer ten questions for every question they ask. So be smart, be cool, and share your knowledge. BAKE ON! blog: http://www.MarianoIglesias.com.ar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Admin Routing Techniques
I had a similar quandry and came up with a simple solution - not to use Cake's admin routing. Instead, I've written an admin controller that gives me a backend admin screen. Whenever I call to a method in another controller, I just use /path/method. In each method, I call a session check method to see if the user has access. Some may disagree with this method, but I feel it gives me more control and I don't have to repeat methods with a normal and admin version. What I haven't done yet is a finer level of control per user group, that next. Tane On 3/23/07, Sonic Baker <[EMAIL PROTECTED]> wrote: > Hi, > > In my current app, I've enables admin routing. There are certain actions I > want to appear in the /admin path. Rather than repeat the logic of the > existing actions in the admin_() actions, I thought it'd be best to just > call these actions from the admin_() actions required. > So, I was wondering if I would be best to simply call either requestAction() > on the required actions, or call the action directly? > > e.g. > Regular Action: > > function add() { > > > // some logic > } > > > Admin Action: > > function admin_add() { > $this->requestAction($this->viewPath . '/add); > $this->render('admin_add'); > } > > or > > function add() { > return $this->add(); > $this->render('admin_add'); > } > > Alternatively, has anyone come up with anything better? > What do you think? > > Cheers, > > Sonic > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Admin Routing Techniques
I don't have a solution, but in your second example, it will never execute the render() method because you're doing a return on the previous line. Maybe just a typo but thought I'd flag it just in case. Adam On Mar 24, 7:12 am, "Sonic Baker" <[EMAIL PROTECTED]> wrote: > Hi, > > In my current app, I've enables admin routing. There are certain actions I > want to appear in the /admin path. Rather than repeat the logic of the > existing actions in the admin_() actions, I thought it'd be best to just > call these actions from the admin_() actions required. > So, I was wondering if I would be best to simply call either requestAction() > on the required actions, or call the action directly? > > e.g. > Regular Action: > > function add() { > > > // some logic > } > > Admin Action: > > function admin_add() { > $this->requestAction($this->viewPath . '/add); > $this->render('admin_add'); > } > > or > > function add() { > return $this->add(); > $this->render('admin_add'); > } > > Alternatively, has anyone come up with anything better? > What do you think? > > Cheers, > > Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Admin Routing Techniques
Hi, In my current app, I've enables admin routing. There are certain actions I want to appear in the /admin path. Rather than repeat the logic of the existing actions in the admin_() actions, I thought it'd be best to just call these actions from the admin_() actions required. So, I was wondering if I would be best to simply call either requestAction() on the required actions, or call the action directly? e.g. Regular Action: function add() { // some logic } Admin Action: function admin_add() { $this->requestAction($this->viewPath . '/add); $this->render('admin_add'); } or function add() { return $this->add(); $this->render('admin_add'); } Alternatively, has anyone come up with anything better? What do you think? Cheers, Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---