I am new to out put class.
What I am trying to achieve is if category not found then will go to my custom not found page.
I think it's working but not sure if I have used this correct $this->output->set_status_header('404');
PHP Code:
<?php
class Category extends MX_Controller {
public function index() {
$get_path = $this->input->get('path');
if (isset($get_path)) {
$path = '';
$parts = explode('_', (string)$get_path);
$category_id = (int)array_pop($parts);
foreach ($parts as $path_id) {
if (!$path) {
$path = (int)$path_id;
} else {
$path .= '_' . (int)$path_id;
}
$category_info = $this->get_category($path_id);
if ($category_info) {
$data['breadcrumbs'][] = array(
'text' => $category_info['name'],
'href' => site_url('page/category') .'/'. '?&path=' . $path
);
}
}
} else {
$category_id = 0;
}
$category_info = $this->get_category($category_id);
if ($category_info) {
$data['text_empty'] = "There are no pages to list in this category.";
// Get Categories
$data['categories'] = array();
// Get Pages
$data['pages'] = array();
$this->load->view('theme/default/template/page/category', $data);
} else {
$this->output->set_status_header('404');
$data['heading_title'] = 'Category not found!';
$data['text_error'] = "Category not found!";
$this->load->view('theme/default/template/error/not_found', $data);
}
}
}
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!