简体   繁体   中英

AppController::redirect() not working in CakePhp 1.3

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM