[英]Cakephp not rendering views
I have a controller, that doesn't render a view (the file is present). 我有一个控制器,它不呈现视图(该文件存在)。 It just simply shows a blank page. 它只是简单地显示一个空白页。
Also it happens only on staging server - two other dev environments work fine. 它也仅在登台服务器上发生-其他两个开发环境可以正常工作。
Here's the code: 这是代码:
function category($catId = null)
{
if (!isset($catId) || empty($catId)) {
$this->data['category'] = 'all';
$this->data['categories'] = $this->ShopCat->find('all',array('order'=>array('ShopCat.title ASC')));
$this->paginate = array(
'limit' => 9,
'order' => array('ShopProd.featured DESC','ShopProd.title ASC')
);
$this->data['products'] = $this->paginate('ShopProd');
} else {
$catId = (int) $catId;
$this->ShopCat->id = $catId;
if (!$this->ShopCat->exists($catId)) $this->cakeError('error404');
$this->data['category'] = $this->ShopCat->find('first', array('ShopCat.id' => $catId));
$this->data['categories'] = $this->ShopCat->find('all',array('order'=>array('ShopCat.title ASC')));
$this->paginate = array(
'conditions' => array('ShopProd.shop_cat_id' => $catId),
'limit' => 9
);
$this->data['products'] = $this->paginate('ShopProd');
}
}
Why isn't this working? 为什么这不起作用? Cause I have no ideas ... 因为我不知道...
UPDATE : the whole controller code runs ok, it just simply doesn't render anything. 更新 :整个控制器代码运行正常,它只是不呈现任何内容。 In other controller methods - all fine, works perfectly. 在其他控制器方法中,一切正常,效果很好。
UPDATE : issue resolved, thanks to everyone :) it was an error in a view file. UPDATE :问题已解决,感谢大家:)这是视图文件中的错误。
Your $catId will always exist. 您的$ catId将始终存在。 You have declared in the function. 您已经在函数中声明了。
Maybe is more useful updated your first if to 也许更有用的是更新您的第一个
if (empty($catId)) {...} 如果(empty($ catId)){...}
Do you have imported the another model in your controller? 您是否已在控制器中导入了另一个模型? Like: $uses = array('ShopCat', 'ShopProd'); 像:$ uses = array('ShopCat','ShopProd');
or use App::import('Model', 'ShopCat') before $this->find 或在$ this-> find之前使用App :: import('Model','ShopCat')
弄清楚了-视图文件中有错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.