2013-04-15 8 views
6

मैं अपने चर जूमला उप नियंत्रक से देखने के लिए इस उदाहरणकैसे नियंत्रक से देखने जूमला MVC

class MYControllerControllerParser extends JController{ 

      public function __construct($default = array()) { 

      parent::__construct($default); 

     } 

    protected function _import($file, $type) { 

      $layout = ''; 
      switch ($type) { 

       case 'importcsv': 
        $contains_headers  = false; 
        $field_separator = JRequest::getVar('separator'); 
        $field_separator = empty($field_separator) ? ',' : $field_separator; 
        $field_enclosure = JRequest::getVar('enclosure');; 
        $field_enclosure = empty($field_enclosure) ? '"' : $field_enclosure; 
//this variable should be passed to the view 
        $this->info = $this->getImportInfoCSV($file, contains_headers, $field_separator, $field_enclosure); 
//This variable should go to view 
        $this->file = basename($file); 
        $layout = 'importcsv'; 
        break; 
      } 

    $this->getView('import','html')->display(); 
    } 
    } 

उत्तर

10

नियंत्रक में के अनुसार पारित करते चर पारित करने के लिए:

$view = $this->getView('import','html'); 
$view->myVariable = 'hello'; 
$view->display(); 

में देखें:

class MycomponentViewItem extends JViewLegacy 
{ 
    /** @var string my variable */ 
    public $myVariable; 

    public function display($tpl = null) 
    { 
    $myVariable = $this->myVariable; 
    //... 
    } 
} 
+0

धन्यवाद बहुत काम कर रहा है !! – fefe

+0

@pirtr_cz लेआउट में इस $ myVariable का उपयोग कैसे करें? –

+1

@ हरसिमरन> लेआउट '$ this-> myVariable' कोशिश करें क्योंकि लेआउट एक दृश्य का हिस्सा है –

संबंधित मुद्दे