public function getCategory($id) { $result['categories'] = $this->category->getCategories(); $result['title'] = 'Shop'; $result['currentCategory'] = $id; $result['isEditor'] = Auth::isUserInRole(array('editor', 'admin')); $result['isAdmin'] = Auth::isUserInRole(array('admin')); if ($result['isEditor']) { $result['products'] = $this->product->getProductsForCategoryWitnUnavailable($id); } else { $result['products'] = $this->product->getProductsForCategory($id); } $all_promotion = $this->promotion->getHighestActivePromotion(); foreach ($result['products'] as $k => $p) { $productPromotion = max($all_promotion['discount'], $p['discount'], $p['category_discount']); if (is_numeric($productPromotion)) { $result['products'][$k]['promotion_price'] = $p['price'] - $p['price'] * ($productPromotion / 100); } } View::make('index', $result); if (Auth::isAuth()) { View::appendTemplateToLayout('topBar', 'top_bar/user'); } else { View::appendTemplateToLayout('topBar', 'top_bar/guest'); } View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->appendTemplateToLayout('catMenu', 'side_bar/category_menu')->render(); }