Reputation: 397
Hi I am adding a dynamic sub menu for CakePHP and get this error:
Notice (8): Undefined property: PagesController::$GamesRewiewTypes
I have created controller called rewiew_types_controller.php
and it doesn't work??
App_Controller.php:
$rewiewTypes = $this->GamesRewiewTypes->find('all', array('conditions' => array('GamesRewiewTypes.menu_show' => 1), 'order' => 'GamesRewiewTypes.title ASC'));
$rewiewTypes = Set::combine($rewiewTypes, '{n}.GamesRewiewTypes.title', array('/reviews/{0}', '{n}.GamesRewiewTypes.id'));
$mainMenu = array(
'3dreviews' => $rewiewTypes,
);
Rewiews_Type_Controller.php:
class RewiewTypesController extends AppController {
var $name = 'rewiewTypes';
var $uses = array('GamesRewiewTypes');
Pages_Controller.php:
class PagesController extends AppController {
var $uses = array('Banner');
public function index() {
$banners = $this->Banner->find('all', array('order' => 'position ASC'));
$this->set('banners', $banners);
/*
pr ($banners);
exit;
*/
}
Upvotes: 4
Views: 550
Reputation: 1
You can load the model within the function
public function someFunc(){
$this->loadModel('Model1','Model2');
//todo
}
Upvotes: 0
Reputation: 2577
Replace $uses in your app_controller and pages_controller with
var $uses = array('Banner','GamesRewiewTypes');
that should do the trick
Upvotes: 4