0

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.

t1gor
  • 1,244
  • 12
  • 25

2 Answers2

1

Your $catId will always exist. You have declared in the function.

Maybe is more useful updated your first if to

if (empty($catId)) {...}


Do you have imported the another model in your controller? Like: $uses = array('ShopCat', 'ShopProd');

or use App::import('Model', 'ShopCat') before $this->find

Claytinho
  • 538
  • 6
  • 21
-2

Figured it out - there was an error in a view file.

t1gor
  • 1,244
  • 12
  • 25