Quantcast

Redirect in a component

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Redirect in a component

will barker
Hi,

Im trying to redirect from a component, and in the cookbook it says
this:

function redirectSomewhere($value) {
                // utilizing a controller method
                $this->controller->redirect($value);
        }


http://book.cakephp.org/view/64/Creating-Components

But that throws an error like this:
**********
 Error:  The component file was not found.

Error: Create the class RedirectComponent in file: app/controllers/
components/redirect.php

<?php
class RedirectComponent extends Object {


}
?>
***********

Can anyone explain why? And what do i do to redirect from my
component?

Thanks!

Will

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Redirect in a component

Okalany Daniel
Hi Will,
I always redirect like this:

$this->controller = null;
// function run on init
function startup(&$controller){
$this->controller = $controller;
}

function someredirect(){
$this->controller->redirect('/');
}


On Tue, Oct 19, 2010 at 10:35 AM, #2Will <[hidden email]> wrote:
Hi,

Im trying to redirect from a component, and in the cookbook it says
this:

function redirectSomewhere($value) {
               // utilizing a controller method
               $this->controller->redirect($value);
       }


http://book.cakephp.org/view/64/Creating-Components

But that throws an error like this:
**********
 Error:  The component file was not found.

Error: Create the class RedirectComponent in file: app/controllers/
components/redirect.php

<?php
class RedirectComponent extends Object {


}
?>
***********

Can anyone explain why? And what do i do to redirect from my
component?

Thanks!

Will

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en



--
OKALANY DANIEL,
P.O BOX 26150,
Kampala.,
Uganda.
http://okasoft.net
--
When confronted by our worst nightmares, the choices are few; Fight or flight. We hope to find the strength to stand against our fears but sometimes, despite ourselves, we run. What if the nightmare gives chase? Where can we hide then?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Redirect in a component

will barker

Thanks Okalany,

Actually, i should have worked this out from the page i posted,

From the cookbook (similar to your code)
function initialize(&$controller, $settings = array()) {
                // saving the controller reference for later use
                $this->controller =& $controller;
        }

But in my tail chasing I'd added further code that was leading to
misinterpreted error messages.  My bad.

Thanks for helping me see.

will


On Oct 19, 6:53 pm, Okalany Daniel <[hidden email]> wrote:

> Hi Will,
> I always redirect like this:
>
> $this->controller = null;
> // function run on init
> function startup(&$controller){
> $this->controller = $controller;
>
> }
>
> function someredirect(){
> $this->controller->redirect('/');
>
>
>
> }
> On Tue, Oct 19, 2010 at 10:35 AM, #2Will <[hidden email]> wrote:
> > Hi,
>
> > Im trying to redirect from a component, and in the cookbook it says
> > this:
>
> > function redirectSomewhere($value) {
> >                // utilizing a controller method
> >                $this->controller->redirect($value);
> >        }
>
> >http://book.cakephp.org/view/64/Creating-Components
>
> > But that throws an error like this:
> > **********
> >  Error:  The component file was not found.
>
> > Error: Create the class RedirectComponent in file: app/controllers/
> > components/redirect.php
>
> > <?php
> > class RedirectComponent extends Object {
>
> > }
> > ?>
> > ***********
>
> > Can anyone explain why? And what do i do to redirect from my
> > component?
>
> > Thanks!
>
> > Will
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to [hidden email]
> > To unsubscribe from this group, send email to
> > [hidden email]<cake-php%[hidden email]>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en
>
> --
> OKALANY DANIEL,
> P.O BOX 26150,
> Kampala.,
> Uganda.http://okasoft.net
> --
> When confronted by our worst nightmares, the choices are few; Fight or
> flight. We hope to find the strength to stand against our fears but
> sometimes, despite ourselves, we run. What if the nightmare gives chase?
> Where can we hide then?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Loading...