Passing data from CakePHP component to a helper


Sourabh Jain

My query was :- Is there any elegant way to pass data from a component to a helper?
Yes, the same way you pass any data to the helper. In your view.
Inside your component I would do something like the following. The beforeRender() action is a CakePHP component callback.

publicfunction beforeRender(Controller $controller){
    $yourVars ='some data';
    $goHere ='other stuff';


Then in your view you can pass the data off to your helpers just like normal.

// view or layout *.ctp file

View original post

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s