Zand Php Cake Php

Posted by : Michael Gaiser
How to inheirt form other controllers?
I want to have my UserAdmin controller inherit from my User
controller instead of AppController. but it cannot seem to find it. Is
there a special way to do this in cake or can I just use and include
statment? Thanks.


 

~MJG
 
 
Posted by : Graham Weldon
Re : How to inheirt form other controllers?
Try something like:



if (!class_exists('
ParentController')) {

    App::import('Controller', 'ParentController');

}

class ChildController extends ParentController {

    // Imeplement controller as normal

}
 
 
Posted by : brian
Re : How to inheirt form other controllers?
Have a look at admin routing. You don't need to have separate

controllers for what you want to do.
 
 
Posted by : Grzegorz Pawlik
Re : How to inheirt form other controllers?
> *Fatal error*: Class 'LocationController' not found in *

> C:\wamp\www\theinconnu\app\controllers\locationmanager_controller.php* on

> line *6



It seems You are importing LocationmanagerController (in app::import),

but

extending class by LocationController, or making some similar

mistake.

Plus, controllers are supposed to be plural, like LocationsController

instead of LocationController  and so, maybe this is Your typo?



>

> *So for the parent controller name, do I use 'Location' or

> 'LocationController'?

>
 
 
Posted by : Michael Gaiser
Re : How to inheirt form other controllers?
Yep. It was part typo as well as me trying to use it wrong. Thanks for the help.

~MJG
 
 
Posted by : Jaydeep Dave
Re : How to inheirt form other controllers?
You can use that controller (Model) in app_controller.php;

var $uses = array('User', 'Curl', 'Services');  // etc ;)

---------------


In your "end" controller you can use something like

$this->User->Controller->method();            // Dont know the exact snippet ... but search in google.
 
 
If you have the better reply, then send it to us. We will display your reply after the approval.
Name : 
Email Id :   
Reply :