Hi again!

I thought it might be a good idea to move various commonly used
controller methods into app_controller.php, to handle normal CRUD
duties and only be overridden for special occasions. For example, I've
now replaced the following method that was in all my controllers, such
as the one for the Author model:

  function admin_index() {
    $this->Author->recursive = 0;
    $this->set('authors', $this->paginate());
  }

...with this in app_controller.php:

  // Pretty much every model has an admin index page, so let's define
that once here
  function admin_index() {
    $modelName = $this->modelClass;
    $controllerName = $this->params['controller'];

    $this->$modelName->recursive = 0;
    $this->set($controllerName, $this->paginate());
  }

It seems to be working just fine, but before I recommend this to
anyone else, I thought I'd just check I've got the right idea. So my
two questions are:

1. Is this a good idea? Should I be doing it at all in the first
place?

2. Am I going about it the right way? Are $this->modelClass and $this-
>params['controller'] the correct variables to use in this case, for
example?

As always, your help is much appreciated!

Thank you very much,
Zoe.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to