2. create a file app_controller.php in /app and write that (or copy
from /cake/app_controller.php):
<?php
class AppController extends Controller {
// callback example
function beforeFilter() {
// will be called for ALL controllers
}
// custom function example
function __myprivate() {
// available in every controller with $this->__myprivate()
}
}
?>
3. look at the content of $this
pr($this)
and you'll see:
$this->name // name of the controller (string)
$this->action // name of the action (string)
$this->params // parameters of the action (array)
$this->passedArgs // named parameters of the action (array)
On 21 août, 12:22, cronet <[EMAIL PROTECTED]> wrote:
> Thank you for your reply.
> 1. Ok. 1 is clear now.
>
> 2. How do i extend AppController?
>
> 3. I wanted to get behind the 'action' Parameter for the beforeFilter
> function, because i only want to use it on specific actions.
> So I thought I look at the API...
>
> On 21 Aug., 12:07, djiize <[EMAIL PROTECTED]> wrote:
>
> > 1. in Cake conventions, function prefixed with __ is private, so
> > you're correct
>
> > 2. if you need to access a function from several controllers, don't
> > put it in a specific one, move it to app_controller.php.
> > Since all your controllers extend AppController, $this->__validateLogin()
> > is OK
>
> > IMHO a validateLogin() function is more in a Model than in a
> > Constroller, but depends of what you're doing in it.
>
> > 3. just override beforeFilter in your controller, and you'll have
> > access to controller's variables with $this.
> > Maybe I don't understand well your question here...
>
> > On 21 août, 11:25, cronet <[EMAIL PROTECTED]> wrote:
>
> > > Hi There,
>
> > > I just started using cake, and having heavy troubles getting some
> > > basic things to work....
>
> > > 1. How do I define a function without a view?
> > > I read somewhere on the net, that these actions/functions start with a
> > > double underscore...
> > > example: function __validateLogin()
> > > Is this okay?
>
> > > 2. How to access the function defined in 1 from other Controllers?
> > > In the same controller i simply use $this->__validateLogin();
> > > But in other controllers?
>
> > > 3. How to get infos from the API?
> > > e.g. i tried to get informations, what parameters could be used in the
> > > beforeFilter function...
> > > I simply searched the api for "beforeFilter" and found the first entry
> > > useful : "Controller::beforeFilter()";
> > > But on line 1127 of file controller.php only
>
> > > 01123 /**
> > > 01124 * Called before the controller action. Overridden in
> > > subclasses.
> > > 01125 *
> > > 01126 */
> > > 01127 function beforeFilter() {
> > > 01128 }
>
> > > Nothing more... Wher can I find the source to get the params section?
>
> > > Perhaps someone could help me and describes how to solve this...
>
> > > Greetings,
> > > Alexander
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---