tags:

views:

115

answers:

2

Hi,

In my cakephp application i need to use my controller in helper.php. Its not working. will any one explain it with little syntax?

+1  A: 

Helpers are not designed to have access to the controller. If you're trying to access the controller you may want to rethink your application design.

I actually had this same problem myself. I have a CakePHP 1.1 application where I was accessing the controller by passing the name of the controller as a parameter to the view. After trying to upgrade the code to work with 1.2 I realized that this was bad design. It was my first experience with CakePHP and MVC, so I chalked that up as a lesson learned.

MVC requires some up-front design to make sure that you're putting your functions in the right places (controller, model, or view).

(P.S. You can also try the #cakephp channel on irc.freenode.net)

Chris Thompson
plz tell me is it correct that helper accessing the modal?
A: 

Its an MVC.

You shouldn't use a Controller in your helper, rather use your helper in your controller.

Why would wan't to do that in the first place.

Read this:

http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

Rishav Rastogi