function delete()
 {
     if ($this->fetch_field('type') == 'category') {
         $this->registry->db->query("delete from " . TABLE_PREFIX . "{$this->table} where type='template' and userid=" . $this->fetch_field('userid') . " and parentid=" . $this->fetch_field('pid'));
     }
     parent::delete();
 }