Advertisement
gareth126

list helper

Nov 16th, 2011
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 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.     //the index action
  12.     public function indexAction()
  13.     {
  14.         $this->view->usernameVar = 'Gareth';    
  15.     }
  16.    
  17.     //the list aciton
  18.     public function listAction()
  19.     {
  20.         $this->view->userList = array ('Scott', 'Gareth', 'Edin', 'Jeremy', 'Michelangelo');
  21.     }
  22.    
  23.     //the __call function is run if the system cannot find the action
  24.     public function __call($method, $args)
  25.     {
  26.         $username = ucwords(substr($method, 0, -6));
  27.         $this->view->usernameVar = $username;
  28.         self::_viewAction();        
  29.     }
  30.      
  31.    
  32.     //this function is protected because its one of our funcitons
  33.     //it is the view action that is called form __call if a users name is not known
  34.     protected function _viewAction()
  35.     {
  36.         //load the index view (no need for phtml)
  37.         $this->render('index');  
  38.     }
  39. }
  40.  
  41. //list action
  42. <div id="view-content">
  43.     <p>The contents of the list is:</p>
  44.     <?php echo $this->htmlList($this->userList); ?>
  45. </div>
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement