How to call controller function in view in Zend Framework?
11,820
Solution 1
First:
public function indexAction()
{
$this->view->controller = $this
}
In your view script:
<html><title><?php echo $this->controller->getResultByID($this->id); ?></title></html>
Solution 2
By using Action View Helper :
http://framework.zend.com/manual/1.12/en/zend.view.helpers.html#zend.view.helpers.initial.action
Author by
user1745968
Updated on June 04, 2022Comments
-
user1745968 almost 2 years
In Zend Framework, I have one controller
class TestController extends Zend_Controller_Action { public function indexAction() { } public function getResultByID( $id ) { return $id; } }
How can I call the function getResultByID in index.phtml ?
-
David Weinraub over 11 yearsDo you really need to call the
getResultByID()
in the view? Why not call that method in the controller and pass the result to the view (which would be the more standard approach)?
-
-
user1745968 over 11 yearsso it's impossible to call the function directly in view?
-
Adarsh Khatri about 8 yearsThis is the best answer I would say. Why people haven't accepted!
-
Kamlesh about 4 yearszend 3 question: How can we fetch cms pages title and their links to display them in header / footer sections of entire website. Pages title and links are stored in database. Please share any suggestion. Thanks.