Today, we are going to see the right way to access view helper inside another view helper in Zend Framework 1.
If you need to access any specific method inside any class, we will create an instance of that class and access the method, this same approach is getting followed when you need to access any view helper inside another vew helper. (Please don't follow this approach)
If you need to access any method (getUserData) inside the user view helper, this below code will work
Hope you enjoyed this post and let me know any feedback or better approach.
If you need to access any specific method inside any class, we will create an instance of that class and access the method, this same approach is getting followed when you need to access any view helper inside another vew helper. (Please don't follow this approach)
<?php $userHelper = new View_Helper_User(); $userHelper->getUserData(); ?>But Zend framework 1, gives you the view object inside view helper and using that view object you can access other view helper. if you need to access any view helper (user), this below code will work
<?php $this->view->user($userId); ?>
If you need to access any method (getUserData) inside the user view helper, this below code will work
<?php $this->view->getHelper('user')->getUserData($article); ?>
Hope you enjoyed this post and let me know any feedback or better approach.
No comments:
Post a Comment