Skip to content
hectorl edited this page Nov 6, 2012 · 1 revision

All controllers are inside the application/controllers/ folder. The basic structure is as follows:

namespace controllers;
use Application;

class Video extends Application
{
     private $smarty;

     public function __construct($smarty) {
          $this->smarty = $smarty;
          $this->load_model('Video_model');//Load the model
     }

     /*
      * Default method loaded in case that there is no method in URL or one that not exists
      *
      * @param array $params Array of URL params
      */
     public function index(){
          //Things to do by default
     }

     /*
      * Load video data, assigns it values to smarty and displays the template.
      *
      * @param array $params Array of URL params, in this case, it will be only the ID
      */
     public function load($params){
          //Things to do with the parameters
          $this->smarty->assign('video_data', $this->Video_model->get_video($params['id']));
          $this->smarty->display('video_view.tpl');
     }
}

Clone this wiki locally