public function process() { parent::process(); if (!($id_category = (int) Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) { $this->errors[] = Tools::displayError('Missing category ID'); } else { if (!Validate::isLoadedObject($this->category)) { $this->errors[] = Tools::displayError('Category does not exist'); } elseif (!$this->category->checkAccess((int) self::$cookie->id_customer)) { $this->errors[] = Tools::displayError('You do not have access to this category.'); } elseif (!$this->category->active) { self::$smarty->assign('category', $this->category); } else { $rewrited_url = self::$link->getCategoryLink((int) $this->category->id, $this->category->link_rewrite); /* Scenes (could be externalised to another controler if you need them */ self::$smarty->assign('scenes', Scene::getScenes((int) $this->category->id, (int) self::$cookie->id_lang, true, false)); /* Scenes images formats */ if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) { foreach ($sceneImageTypes as $sceneImageType) { if ($sceneImageType['name'] == 'thumb_scene') { $thumbSceneImageType = $sceneImageType; } elseif ($sceneImageType['name'] == 'large_scene') { $largeSceneImageType = $sceneImageType; } } self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL); self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL); } $this->category->description = nl2br2($this->category->description); $subCategories = $this->category->getSubCategories((int) self::$cookie->id_lang); self::$smarty->assign('category', $this->category); if (isset($subCategories) and !empty($subCategories) and $subCategories) { self::$smarty->assign('subcategories', $subCategories); self::$smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2))); } if ($this->category->id != 1) { $this->productListAssign(); } self::$smarty->assign(array('products' => (isset($this->cat_products) and $this->cat_products) ? $this->cat_products : NULL, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int) $this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home'))); if (isset(self::$cookie->id_customer)) { self::$smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts((int) self::$cookie->id_customer)); } elseif (isset(self::$cookie->id_guest)) { self::$smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts((int) self::$cookie->id_guest)); } } } self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers())); }
/** * Assigns scenes template variables */ protected function assignScenes() { // Scenes (could be externalised to another controller if you need them) $scenes = Scene::getScenes($this->category->id, $this->context->language->id, true, false); $this->context->smarty->assign('scenes', $scenes); // Scenes images formats if ($scenes && ($scene_image_types = ImageType::getImagesTypes('scenes'))) { foreach ($scene_image_types as $scene_image_type) { if ($scene_image_type['name'] == ImageType::getFormatedName('m_scene')) { $thumb_scene_image_type = $scene_image_type; } elseif ($scene_image_type['name'] == ImageType::getFormatedName('scene')) { $large_scene_image_type = $scene_image_type; } } $this->context->smarty->assign(array('thumbSceneImageType' => isset($thumb_scene_image_type) ? $thumb_scene_image_type : null, 'largeSceneImageType' => isset($large_scene_image_type) ? $large_scene_image_type : null)); } }
public function process() { parent::process(); if (!($id_category = (int) Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) { $this->errors[] = Tools::displayError('Missing category ID'); } else { if (!Validate::isLoadedObject($this->category)) { $this->errors[] = Tools::displayError('Category does not exist'); } elseif (!$this->category->checkAccess((int) self::$cookie->id_customer)) { $this->errors[] = Tools::displayError('You do not have access to this category.'); } elseif (!$this->category->active) { self::$smarty->assign('category', $this->category); } else { $rewrited_url = self::$link->getCategoryLink((int) $this->category->id, $this->category->link_rewrite); /* Scenes (could be externalised to another controler if you need them */ self::$smarty->assign('scenes', Scene::getScenes((int) $this->category->id, (int) self::$cookie->id_lang, true, false)); /* Scenes images formats */ if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) { foreach ($sceneImageTypes as $sceneImageType) { if ($sceneImageType['name'] == 'thumb_scene') { $thumbSceneImageType = $sceneImageType; } elseif ($sceneImageType['name'] == 'large_scene') { $largeSceneImageType = $sceneImageType; } } self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL); self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL); } $this->category->description = nl2br2($this->category->description); $subCategories = $this->category->getSubCategories((int) self::$cookie->id_lang); self::$smarty->assign('category', $this->category); if (Db::getInstance()->numRows()) { self::$smarty->assign('subcategories', $subCategories); self::$smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2))); } if ($this->category->id != 1) { $nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int) $nbProducts); self::$smarty->assign('nb_products', (int) $nbProducts); $cat_products = $this->category->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay); if ($cat_products) { foreach ($cat_products as $cat_product) { $prod_features[$cat_product["id_product"]] = Product::getFrontFeaturesStatic(self::$cookie->id_lang, $cat_product['id_product']); $aux_product = new Product($cat_product["id_product"], true, self::$cookie->id_lang); $aux_attributesGroups = $aux_product->getAttributesGroups((int) self::$cookie->id_lang); foreach ($aux_attributesGroups as $k => $row) { $aux_combinations[$row['attribute_name']]['price'] = (double) $row['price']; } $prod_combinations[$cat_product["id_product"]] = $aux_combinations; unset($aux_combinations); } } } if (isset($prod_features)) { self::$smarty->assign('prod_features', $prod_features); } if (isset($prod_combinations)) { self::$smarty->assign('prod_combinations', $prod_combinations); } self::$smarty->assign(array('products' => (isset($cat_products) and $cat_products) ? $cat_products : NULL, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int) $this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home'))); foreach ($subCategories as $subCat) { $secondLevelCats[$subCat["id_category"]] = $this->getSubCats($subCat["id_category"]); } if (isset($secondLevelCats)) { self::$smarty->assign('secondLevelCats', $secondLevelCats); } } } self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers())); }
include dirname(__FILE__) . '/header.php'; include dirname(__FILE__) . '/product-sort.php'; $errors = array(); if (!isset($_GET['id_category']) or !Validate::isUnsignedId($_GET['id_category'])) { $errors[] = Tools::displayError('category ID is missing'); } else { $category = new Category(intval(Tools::getValue('id_category')), intval($cookie->id_lang)); if (!Validate::isLoadedObject($category)) { $errors[] = Tools::displayError('category does not exist'); } elseif (!$category->checkAccess(intval($cookie->id_customer))) { $errors[] = Tools::displayError('you do not have access to this category'); } else { /* rewrited url set */ $rewrited_url = $link->getCategoryLink($category->id, $category->link_rewrite); /* Scenes (could be externalised to another controler if you need them */ $smarty->assign('scenes', Scene::getScenes(intval($category->id), intval($cookie->id_lang), true, false)); /* Scenes images formats */ if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) { foreach ($sceneImageTypes as $sceneImageType) { if ($sceneImageType['name'] == 'thumb_scene') { $thumbSceneImageType = $sceneImageType; } elseif ($sceneImageType['name'] == 'large_scene') { $largeSceneImageType = $sceneImageType; } } $smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL); $smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL); } $category->name = Category::hideCategoryPosition($category->name); $category->description = nl2br2($category->description); $subCategories = $category->getSubCategories(intval($cookie->id_lang));
private function smartOverloARd() { //must be called in hookDisplayFooter to Work if (Tools::getValue('controller') == 'category') { $idCat = Tools::getValue('id_category'); $scene = Scene::getScenes($idCat, $this->context->language->id, true, true); if ($scene) { //if there is a scene we stop we don't display the slider and let the scene show return; } $this->categorySlide = $this->getCategorySlide($idCat); //check if we have a slide for this category if ($this->categorySlide) { //we have a slide so let's remove the category image if ($this->hasActiveSlides($this->categorySlide)) { //check if there is any active slide $category = $this->context->smarty->getVariable('category'); $category = $category->value; $category->id_image = 0; } } } if (Tools::getValue('controller') == 'cms' && Tools::getValue('id_cms') != '') { $cms = $this->context->smarty->getVariable('cms'); //$this->context->smarty->clearAssign('cms'); $cms = $cms->value; if (isset($cms->content) && !empty($cms->content)) { $cms->content = $this->doShortcode($cms->content); //$this->context->smarty->assign('cms', $cms); } } if (Tools::getValue('controller') == 'product' && Tools::getValue('id_product') != '') { $product = $this->context->smarty->getVariable('product'); $product = $product->value; $this->product = $product; $product->description = $this->doShortcode($product->description); } }