После добавления этого в конец моей display
функции внутри app/controllers/pages_controller.php
,
// grab all message lists
$this->loadModel('MessageList');
$this->set('messageLists', $this->MessageList->find('all'));
Я пытаюсь получить к ней доступ в app/views/pages/home.ctp
, как
<?php
foreach($messageLists as $messageList) {
print_r($messageList);
}
?>
Но яполучите предупреждение
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
на своей домашней странице?Спасибо!