I want to use "getpoll" ,which is action of users controller ,in another controller(events controller).
How can i use it?
in advance thanks...to all...
You can use requestAction method of the controller:
$this->requestAction('/comments/latest');
you can call it differently depending on your needs for details look for the link:
Link to CookBook: Controller requestAction Method
You should write the db query of the getPoll()
action as a method in the poll model, that way in your user controller you can just call $this->User->Poll->getPolls()
to grab the polls, and if associations are setup correctly, $this->Event->Poll->getPolls()
from your events controller.
For example in your poll model:
public function getPoll($userId = null) {
return $this->find('all', array(..));
}
You could share a common piece of code between controllers with components.
http://book.cakephp.org/view/994/Introduction
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With