// grab all message lists
$this->loadModel('MessageList');
$this->set('messageLists', $this->MessageList->find('all'));
、app/controllers/pages_controller.php
内部の私のdisplay
関数の最後にこれを追加した後、ホームページ用の変数を設定する私は
<?php
foreach($messageLists as $messageList) {
print_r($messageList);
}
?>
ようapp/views/pages/home.ctp
でそれにアクセスしようしかし、私は警告を受けます
Notice (8): Undefined variable: messageLists [APP\views\pages\home.ctp, line 9]
私のapp/config/routes.php
は持っている:
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/views/pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
私は私のホームページに$messageLists
にアクセスできるように変更するには何が必要ですか?ありがとう!
'<?php \t \t $ messageLists = $ this-> requestAction(array( 'controller' => 'メッセージ'リスト、 'アクション' => 'getAll'))); \t \t print_r($ messageLists); \t \t \t \t} \t?> 'それは私に無限のリダイレクトループを与えます:S – Garrett
$ this-> MessageList-> find( 'all')); return;それともまだ設定していますか? – burzum