不承认我的观点

时间:2011-12-08 01:11:03

标签: cakephp cakephp-1.3 cakephp-1.2

我是Cake PHP的新手,这个设置给我一个问题..我遵循惯例,除非你指出我正确的方向(我可能会错过的东西)

我有这个控制器

dish_categories_controller.php

<?php
class DishCategoriesController extends AppController {

    var $name = 'Dish_Categories';

    var $uses = array("DishCategory");

    function get_categories($id)
    {
       $this->set('dish_categories',$this->DishCategory->find('first', array('conditions' => array('DishCategory.category_id' == $id))));
       $this->layout = 'master_layout';
    }   
  }
?>

模特

dish_category.php

<?php
class DishCategory extends AppModel{

    var $name = 'DishCategory';
 }
?>

查看

foder:  dish_categories
file:  get_categories.ctp
<?php
print_r($dish_categories);
?>

但是这个网址出现以下错误

myweb/app/dish_categories/get_categories/1


Error: The view for Dish_CategoriesController::get_categories() was not found.

Error: Confirm you have created the file: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\myweb\app\views\dish__categories\get_categories.ctp

感谢您对此事的帮助

谢谢

1 个答案:

答案 0 :(得分:1)

错误很明显:

Confirm you have created the file: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\myweb\app\views\dish__categories\get_categories.ctp

您的视图必须与操作名称同名。即 get_categories.ctp ,而不是像现在这样的dish_categories.ctp。

编辑:

htdocs\myweb\app\views\dish__categories\

在dish__categories中有2个下划线

尝试删除此行:

var $name = 'Dish_Categories';