dvir Posted September 1, 2016 Share Posted September 1, 2016 hi, i have category pages with a lot of products. for example : https://www.cdsoft.co.il/index.php?id_category=7&controller=category&id_lang=3&p=4 https://www.cdsoft.co.il/index.php?id_category=7&controller=category&id_lang=3&p=3 https://www.cdsoft.co.il/index.php?id_category=7&controller=category&id_lang=3&p=2 they all have the same meta title . i want to add to each meta title " page number XX" HOW TO DO IT ? Link to comment Share on other sites More sharing options...
rocky Posted September 2, 2016 Share Posted September 2, 2016 Try creating override/classes/Meta.php with the following: <?php class Meta extends MetaCore { public static function getCategoryMetas($id_category, $id_lang, $page_name, $title = '') { $metas = MetaCore::getCategoryMetas($id_category, $id_lang, $page_name, $title); if ((int)Tools::getValue('p') > 1) { $metas['meta_title'] .= ' (page '.(int)Tools::getValue('p').')'; } return $metas; } } This should add the page number in brackets to the meta-title if there is more than one page. The first page will not have any page number. Remember to go to Advanced Parameters > Performance and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override. Link to comment Share on other sites More sharing options...
dvir Posted September 2, 2016 Author Share Posted September 2, 2016 hi, thanks for the reply - but still, i cant see any number on the meta title . i tried to look at category meta title and on sub - category - nothing.. Link to comment Share on other sites More sharing options...
rocky Posted September 2, 2016 Share Posted September 2, 2016 Seems this is harder than I thought it would be. Strangely, when I check my PrestaShop v1.6.1.6 test site, it is already adding the page number to the meta-title. I see Women on the first page and Women (2) on the second page. I'm not sure why your PrestaShop isn't already doing this. Link to comment Share on other sites More sharing options...
dvir Posted September 2, 2016 Author Share Posted September 2, 2016 i have 1.6.1.4 Link to comment Share on other sites More sharing options...
rocky Posted September 2, 2016 Share Posted September 2, 2016 Here's what my Meta::getCategoryMetas function looks like from classes/Meta.php: public static function getCategoryMetas($id_category, $id_lang, $page_name, $title = '') { if (!empty($title)) { $title = ' - '.$title; } $page_number = (int)Tools::getValue('p'); $sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description` FROM `'._DB_PREFIX_.'category_lang` cl WHERE cl.`id_lang` = '.(int)$id_lang.' AND cl.`id_category` = '.(int)$id_category.Shop::addSqlRestrictionOnLang('cl'); $cache_id = 'Meta::getCategoryMetas'.(int)$id_category.'-'.(int)$id_lang; if (!Cache::isStored($cache_id)) { if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) { if (empty($row['meta_description'])) { $row['meta_description'] = strip_tags($row['description']); } // Paginate title if (!empty($row['meta_title'])) { $row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME'); } else { $row['meta_title'] = $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME'); } if (!empty($title)) { $row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME'); } $result = Meta::completeMetaTags($row, $row['name']); } else { $result = Meta::getHomeMetas($id_lang, $page_name); } Cache::store($cache_id, $result); return $result; } return Cache::retrieve($cache_id); } As you can see, it's already adding the page number to the meta-title. Does your function have this code? Link to comment Share on other sites More sharing options...
dvir Posted September 2, 2016 Author Share Posted September 2, 2016 YES - it's the same. this is why is so weird. maybe i'm not getting to the meta file, because some module i have ? i think i have seo module that I've bought , but how can i know what is the reason ? Link to comment Share on other sites More sharing options...
rocky Posted September 2, 2016 Share Posted September 2, 2016 You can try going to the Advanced Parameters > Performance tab and changing "Disable non PrestaShop modules" and "Disable all overrides" to "Yes". If the page number appears, then it's a module or override. Link to comment Share on other sites More sharing options...
dvir Posted September 2, 2016 Author Share Posted September 2, 2016 i did it - but still nothing . i've disabled all the non- prestashop module + disable all overrides. and i'm still not getting any page number on the meta title Link to comment Share on other sites More sharing options...
dvir Posted September 2, 2016 Author Share Posted September 2, 2016 hi - I've found it i'm using blocklayered module , and there is a function call Ajax call. when i'm using blocklayered- the meta title comes from the ajax function so - with the help of Yaniv Mirel - in line 3174 , on module/blocklayered/blocklayered.php - line 3174 : 'meta_title' => $meta_title . ' | ' . $this->l('page') . ' ' . $p . ' - ' . Configuration::get('PS_SHOP_NAME'), Link to comment Share on other sites More sharing options...
scardovi Posted April 14, 2018 Share Posted April 14, 2018 Have you solved? Stefano Link to comment Share on other sites More sharing options...
DARKF3D3 Posted May 27, 2019 Share Posted May 27, 2019 I'm interested too. I need to do this on PS1.7.4.2. Any help? Link to comment Share on other sites More sharing options...
ecentury Posted August 29, 2019 Share Posted August 29, 2019 In prestashop 1.6 i just add the folowing to add the page number to the title or any other meta info, just add it to the header.tpl using the smarty ability to get page ({$smarty.get.p}) i.e. <title>{$meta_title|escape:'html':'UTF-8'|truncate:120:"":false}{if isset($smarty.get.p) && $smarty.get.p} ({$smarty.get.p}){/if}</title> Link to comment Share on other sites More sharing options...
DARKF3D3 Posted September 25, 2019 Share Posted September 25, 2019 I tried using {$smarty.get.p} on PS1.7 but unfortunatelly it doesn't works. Link to comment Share on other sites More sharing options...
rocky Posted September 27, 2019 Share Posted September 27, 2019 I think it's changed to {$smarty.get.page} in PrestaShop v1.7. Link to comment Share on other sites More sharing options...
DARKF3D3 Posted October 7, 2019 Share Posted October 7, 2019 Thank you rocky, with {$smarty.get.page} worked. Link to comment Share on other sites More sharing options...
Riva Posted October 5, 2020 Share Posted October 5, 2020 PS 1.7 How to remove page nomber meta title? Link to comment Share on other sites More sharing options...
HaCos Posted July 16, 2023 Share Posted July 16, 2023 (edited) Can you extend this class to add the page number also in meta description? Edited July 16, 2023 by HaCos (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now