admin_webs Posted May 14, 2012 Share Posted May 14, 2012 (edited) Hello! Does anybody know how to make a different title in different page of category? For exemplum: page: /10-podarochnye-fleshki - title: originale usb drive page: /10-podarochnye-fleshki?p=2 - title: perfect usb drive Are there some modul? Edited May 17, 2012 by admin_webs (see edit history) Link to comment Share on other sites More sharing options...
admin_webs Posted May 16, 2012 Author Share Posted May 16, 2012 (edited) I heve solved it: in tools.php change function getMetaTags /* Categories specifics meta tags */ elseif ($id_category = self::getValue('id_category')) { if (!empty($title)) $title = ' - '.$title; $page_number = (int)self::getValue('p'); $row = false; $indiv_title = false; if(!empty($page_number)){ $query = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description` FROM `'._DB_PREFIX_.'category_lang` WHERE id_lang = '.(int)($id_lang).' AND id_category = '.(int)($id_category).' AND page = '.$page_number; $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query); } if(empty($row)){ $query = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description` FROM `'._DB_PREFIX_.'category_lang` WHERE id_lang = '.(int)($id_lang).' AND id_category = '.(int)($id_category).' AND page IS NULL'; $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query); } else{ $indiv_title = true; } if ($row) { if (empty($row['meta_description'])) $row['meta_description'] = strip_tags($row['description']); // Paginate title if (!empty($row['meta_title'])&&!empty($indiv_title)) $row['meta_title'] = $title.$row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME'); elseif (!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'); return self::completeMetaTags($row, $row['name']); } } and change tabel category_lang: delete primary key; and add new colum page; for now it only by using phpmyadmin but tomorrow I will improve it and make some checking Edited May 17, 2012 by admin_webs (see edit history) Link to comment Share on other sites More sharing options...
admin_webs Posted May 17, 2012 Author Share Posted May 17, 2012 top solution is wrong! It works for title but make many bugs. I have make new solution creat new table CREATE TABLE IF NOT EXISTS `ps_category_title` ( `id_category` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `page` int(10) unsigned NOT NULL, `meta_title` varchar(128) NOT NULL, PRIMARY KEY (`id_category`,`id_lang`,`page`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; and change code in tools.php change function getMetaTags for this: /* Categories specifics meta tags */ elseif ($id_category = self::getValue('id_category')) { if (!empty($title)) $title = ' - '.$title; $page_number = (int)self::getValue('p'); $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description` FROM `'._DB_PREFIX_.'category_lang` WHERE id_lang = '.(int)($id_lang).' AND id_category = '.(int)($id_category)); if(!empty($page_number)){ $row2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT `meta_title` FROM `'._DB_PREFIX_.'category_title` WHERE id_lang = '.(int)($id_lang).' AND id_category = '.(int)($id_category).' AND page = '.$page_number); if($row2['meta_title']){ $row['meta_title'] = $row2['meta_title']; } } if ($row) { 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'); return self::completeMetaTags($row, $row['name']); } } 1 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