/** * Display a particular group with all its products * * For example, display the "Electronics" category with all the products that belong to it * * @return string */ public function handleGroup($section, $action, $page) { //The $section variable is the class name and group name //It might be: Category, ProductType, or Supplier $group = new $section($page); if ($group->getId()) { $this->smarty->assign('group', $group); $products = Product::searchProducts(array($section => $page)); $this->smarty->assign('products', $products); } else { $page = 0; } if ($page == 0 || $section == "Category") { //Display the groups in case there is no particular group selected, or we're viewing the sub categories of a category $results = call_user_func(array($section, 'getAll'), true, $page); //Get all the records $this->smarty->assign('results', $results); } return $this->smarty->fetch("DisplayGroupWithProduct.tpl"); }