2013-12-10 23 views
0

我有這樣的錯誤:CakePHP的2.X:如何將數據傳遞到的意見

Notice (8): Undefined variable: informations [APP/View/Information/index.ctp, line 2] 

我有這個功能在我的控制器

public function index($slug){ 
     $this->layout = 'sbhealth'; 
     $this->loadModel('Menu'); 
     $informations = $this->Menu->findBySlug($slug); 
     if($informations){ 
      $this->set('index', $informations); 
     }else{ 
      return $informations = "not find"; 
     } 
    } 

我需要DATAS傳遞給我的看法「 index.ctp「index.ctp然後會在我的數組中找到ID以將它傳遞給Element。但視圖不承認「$信息」

回答

1

這可能因爲它在這本書很詳細自行指定不構成的東西,應該是在計算器上,但是......

// in your controller 
$this->set('informations', $informations); 

的第一項是在視圖中可用的變量的名稱。

第二項是您想要放入該變量的值。

+0

感謝戴夫的幫助,我的壞,我第一個是我在Codeigniter的想法:! –

+0

thks!我必須等待幾分鐘! –

相關問題