public function initContent() { parent::initContent(); include_once dirname(__FILE__) . '/../../../modules/eicmslinks/eicmslinks.php'; //Module EiCmsLinks : On récupère les liens dynamiques des catégories $this->category->description = EiCmsLinks::updateCmsLinksDisplay($this->category->description); $this->context->smarty->assign(array('description_short' => Tools::truncateString(EiCmsLinks::updateCmsLinksDisplay($this->category->description), 350), 'category' => $this->category)); }
public function init() { global $smarty; parent::init(); if (Module::isInstalled('agilesellerratings')) { include_once _PS_ROOT_DIR_ . "/modules/agilesellerratings/agilesellerratings.php"; $smarty->assign(array('cate_seller_ratting' => AgileSellerRatings::getAverageRating4Category($this->category->id))); } }
public function initContent() { parent::initContent(); if (method_exists('Product', 'getProductsImgs')) { $image_array = array(); for ($i = 0; $i < count($this->cat_products); $i++) { if (isset($this->cat_products[$i]['id_product'])) { $image_array[$this->cat_products[$i]['id_product']] = Product::getProductsImgs($this->cat_products[$i]['id_product']); } } $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL); } }
public function init() { if ($category_rewrite = Tools::getValue('category_rewrite')) { $sql = 'SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_lang` WHERE `link_rewrite` = \'' . pSQL(str_replace('.html', '', $category_rewrite)) . '\' AND `id_lang` = ' . Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID(); } $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); if ($id_category > 0) { $_GET['id_category'] = $id_category; } } parent::init(); }
public function init() { if (Tools::getValue('category_rewrite')) { // SQL safe? $category_rewrite = Tools::getValue('category_rewrite'); $sql = 'SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_lang` WHERE `link_rewrite` = \'' . $category_rewrite . '\' AND `id_lang` = ' . Context::getContext()->language->id; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID(); } $categorys_list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); $categorys_count = count($categorys_list); if ($categorys_count == 1) { // Found ONLY one so dont need to look for parent $id_category = (int) $categorys_list[0]['id_category']; $_GET['noredirect'] = TRUE; } else { if ($categorys_count > 1) { // Found more than one so look for parent // SQL safe? $parent_rewrite = Tools::getValue('categories_rewrite'); $shop_id = (int) Shop::getContextShopID(); $sql = 'SELECT c.`id_category` FROM `ps_category` c LEFT JOIN `ps_category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.id_shop = ' . $shop_id . ' ) INNER JOIN ps_category_shop category_shop ON (category_shop.id_category = c.id_category AND category_shop.id_shop = ' . $shop_id . ') LEFT JOIN `ps_category_lang` clp ON (c.`id_parent` = clp.`id_category`) WHERE cl.`link_rewrite` = \'' . $category_rewrite . '\' AND clp.`link_rewrite` = \'' . $parent_rewrite . '\' AND cl.`id_lang` = ' . Context::getContext()->language->id; $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); $_GET['noredirect'] = TRUE; } else { // none found $id_category = 0; } } if ($id_category > 0) { $_GET['id_category'] = $id_category; } else { //TODO: Do we need to send 404? header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); } } parent::init(); }
public function init() { if (Tools::getValue('category_rewrite')) { $category_rewrite = Tools::getValue('category_rewrite'); $id_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_lang` WHERE `link_rewrite` = \'' . $category_rewrite . '\''); if ($id_category > 0) { $_GET['id_category'] = $id_category; //$_GET['noredirect'] = 1; } else { Tools::display404Error(); die; } } parent::init(); }
/** * Method init() : Initialize category controller with category_rewrite params * * @module now_seo_links * * @see CategoryControllerCore::init() */ public function init() { // Get rewrite $sRewrite = Tools::getValue('category_rewrite', false); if ($sRewrite) { $iIdCategory = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_lang` WHERE `link_rewrite` = \'' . $sRewrite . '\' AND `id_lang` = ' . Context::getContext()->language->id); if ($iIdCategory) { $_GET['id_category'] = $iIdCategory; } } parent::init(); // On vérifie si l'URL actuelle est correcte ou pas $goodUrl = Context::getContext()->link->getCategoryLink($this->category); if (!preg_match('#' . $_SERVER['REDIRECT_URL'] . '#', $goodUrl)) { header('Status: 301 Moved Permanently', false, 301); header('Location: ' . $goodUrl); exit; } }
public function initContent() { parent::initContent(); Context::getContext()->cookie->categoryOrderBy = $this->orderBy; Context::getContext()->cookie->categoryOrderWay = $this->orderWay; }
private function _assignForProductsResults() { if (version_compare(_PS_VERSION_, '1.4.0.0', '>=')) { $css_files = array(); $js_files = array(); if (version_compare(_PS_VERSION_, '1.5.0.0', '<')) { include_once _PS_ROOT_DIR_ . '/controllers/CategoryController.php'; $CategoryController = new CategoryControllerCore(); $CategoryController->setMedia(); } if (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && !sizeof($this->_context->controller->css_files) || version_compare(_PS_VERSION_, '1.5.0.0', '<') && !sizeof($css_files)) { $css_files = array(_PS_CSS_DIR_ . 'jquery.cluetip.css' => 'all', _THEME_CSS_DIR_ . 'scenes.css' => 'all', _THEME_CSS_DIR_ . 'category.css' => 'all', _THEME_CSS_DIR_ . 'product_list.css' => 'all'); } if (!sizeof($js_files)) { if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0) { $js_files = array(_THEME_JS_DIR_ . 'products-comparison.js'); } } $this->_smarty->assign(array('comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'css_files_result_search' => $css_files, 'js_files_result_search' => $js_files)); } if (Tools::getIsset('id_seo') && (int) Tools::getValue('id_seo') > 0) { $resultSeoUrl = AdvancedSearchSeoClass::getSeoSearchByIdSeo((int) Tools::getValue('id_seo'), (int) $this->_cookie->id_lang); if (self::_isFilledArray($resultSeoUrl)) { $this->_smarty->assign(array('as_seo_title' => $resultSeoUrl[0]['title'], 'as_seo_description' => $resultSeoUrl[0]['description'])); } } $this->_smarty->assign(array('categorySize' => $this->_getImageSize('category'), 'mediumSize' => $this->_getImageSize('medium'), 'thumbSceneSize' => $this->_getImageSize('thumb_scene'), 'homeSize' => $this->_getImageSize('home'), 'static_token' => Tools::getToken(false))); }