public function action_index($code = null) { if (empty($code) || !Model_Base_Category::valid_by(array(array('code' => $code), array('status' => 1)))) { Response::redirect('/'); } $category_id = Model_Base_Category::get_id_by_code($code); $total_page = ceil(Model_Base_Product::count_by_category($category_id) / _DEFAULT_LIMIT_); View::set_global('total_page', $total_page); $this->data['products'] = Model_Base_Product::get_by_category($category_id); $this->template->title = 'Category Page'; $this->template->content = View::forge($this->layout . '/category/list', $this->data); }