Question

I have a redirect in a view that was working correctly under CakePHP 1.2. I just upgraded to 1.3, and this one page redirect quit working. I'm assuming it's something simple, but couldn't find anything about it in the migration documentation.

in my views\about\index.ctp, I have this line:

AppController::redirect("howitworks/index");

When I hit that about/index page, I get this error:

Notice (8): Undefined property: View::$Component [CORE\cake\libs\controller\controller.php, line 678]

Fatal error: Call to a member function beforeRedirect() on a non-object in "{localaddress}"\cake\libs\controller\controller.php on line 678

I cannot simply route the page, because the redirect is part of an if sequence where if the controller does not supply any text to the .ctp, it redirects away to this other page. I stripped out all that code so that only the redirect remained, to be sure this was the problem.

Can you direct me how to fix this please?

Was it helpful?

Solution

I did as @dhofstet suggested, and just rewrote it so the redirect is in the controller. Not sure why the original worked, but it is cake practice to redirect in the controller, as he said.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top