CakePHP Controller - PullRequest
       1

CakePHP Controller

4 голосов
/ 25 октября 2011

Привет! Я добавляю динамическое подменю для CakePHP и получаю эту ошибку:

Notice (8): Undefined property: PagesController::$GamesRewiewTypes

Я создал контроллер с именем rewiew_types_controller.php, и он не работает ??

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;
    */
}

Ответы [ 2 ]

4 голосов
/ 25 октября 2011

Замените $ использует в вашем app_controller и pages_controller на

var $uses = array('Banner','GamesRewiewTypes');

, который должен сделать трюк

0 голосов
/ 09 сентября 2015

Вы можете загрузить модель в функции

public function someFunc(){ 
   $this->loadModel('Model1','Model2');
   //todo
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...