Advertisement
dragonbe

view helper fix

Nov 16th, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. class UsersController extends Zend_Controller_Action
  4. {
  5.  
  6.     public function init()
  7.     {
  8.         /* Initialize action controller here */
  9.     }
  10.  
  11.     public function indexAction()
  12.     {
  13.  
  14.         $this->view->username = 'Jeremy';
  15.         $this->_viewAction();
  16.                
  17.     }
  18.    
  19.     public function listAction()
  20.     {
  21.  
  22.         $this->view->userList = array('Jeremy', 'Scott', 'Edin', 'Gareth');
  23.        
  24.     }
  25.  
  26.     public function __call($method, $args)
  27.     {
  28.        
  29.         $username = ucwords(substr($method, 0, -6));
  30.         $this->view->username = $username;
  31.         $this->_viewAction();
  32.        
  33.     }
  34.    
  35.     protected function _viewAction()
  36.     {
  37.    
  38.         $this->render('user');
  39.    
  40.     }
  41.    
  42. }
  43.  
  44. //view
  45. <?php if (!empty($this->userList)): ?>
  46. <div><?php echo $this->htmlList($this->userList) ; ?></div>
  47. <?php else: ?>
  48. <div>No users available</div>
  49. <?php endif; ?>
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement