function admin_delete($id = null) { if (!$id) { $this->Session->setFlash('That Category could not be found', true); $this->redirect($this->referer()); } $count = $this->Category->find('count', array('conditions' => array('Category.parent_id' => $id))); if ($count > 0) { $this->Session->setFlash(__('This Category has sub-categories.', true)); $this->redirect($this->referer()); } $category = $this->Category->read(null, $id); if (!empty($category['Content'])) { $this->Session->setFlash(__('There are still content itmes in this category. Remove them and try again.', true)); $this->redirect($this->referer()); } return parent::admin_delete($id); }