2grosiek7 Posted May 1, 2013 Share Posted May 1, 2013 Hi, I am looking for the solution to get name of category to page title. Anyone could help? Link to comment Share on other sites More sharing options...
vekia Posted May 1, 2013 Share Posted May 1, 2013 Hey grosiek :-) where you exactly want to insert the category name to the meta tag? By default - on category pages - category name appears correctly in the title http://i.imgur.com/ym7p3rB.png looks familiar? ;) Link to comment Share on other sites More sharing options...
2grosiek7 Posted May 1, 2013 Author Share Posted May 1, 2013 Yeah, but I forget to say where I want the category name in page title. So, I want to get name of category in the title of product page. Link to comment Share on other sites More sharing options...
vekia Posted May 1, 2013 Share Posted May 1, 2013 you have to change Meta class, go to the classes\Meta.php and look for function: public static function getProductMetas($id_product, $id_lang, $page_name) { ... } You need use script for getting category name: $sql = 'SELECT id_category_default FROM `'._DB_PREFIX_.'product` WHERE id_product = '.(int)$id_product.''; $row_cat = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); $cat=new Category($row_cat['id_category_default'],(int)$id_lang); $row['meta_title']=$row['meta_title']." ".$cat->name; paste it into getProductMetas() function, to the if condition: if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) { ------- HERE ------- if (empty($row['meta_description'])) $row['meta_description'] = strip_tags($row['description_short']); return Meta::completeMetaTags($row, $row['name']); } final modified function: public static function getProductMetas($id_product, $id_lang, $page_name) { $sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description_short` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`'.Shop::addSqlRestrictionOnLang('pl').') '.Shop::addSqlAssociation('product', 'p').' WHERE pl.id_lang = '.(int)$id_lang.' AND pl.id_product = '.(int)$id_product.' AND product_shop.active = 1'; if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) { $sql = 'SELECT id_category_default FROM `'._DB_PREFIX_.'product` WHERE id_product = '.(int)$id_product.''; $row_cat = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); $cat=new Category($row_cat['id_category_default'],(int)$id_lang); $row['meta_title']=$row['meta_title']." ".$cat->name; if (empty($row['meta_description'])) $row['meta_description'] = strip_tags($row['description_short']); return Meta::completeMetaTags($row, $row['name']); } return Meta::getHomeMetas($id_lang, $page_name); } the most important thing in code above is a part below: $row['meta_title']=$row['meta_title']." ".$cat->name; $row['name'] - product name $cat->name - category name your tittle will looks like: "Macbook Laptops" 2 Link to comment Share on other sites More sharing options...
2grosiek7 Posted May 1, 2013 Author Share Posted May 1, 2013 (edited) Working! Thanks! Edited May 1, 2013 by 2grosiek7 (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 1, 2013 Share Posted May 1, 2013 you're welcome ;-) i marked this thread as solved regards 1 Link to comment Share on other sites More sharing options...
Martin C Posted June 28, 2013 Share Posted June 28, 2013 Hi Vekia, Great solution, but if i want to have all the categories in the metatitle? For example: home - childgifts - moneybanks. Can you help me out with this query? Link to comment Share on other sites More sharing options...
vekia Posted June 28, 2013 Share Posted June 28, 2013 then it will be necessary to change the code a bit, the most important thing: change the mysql query for all categories (with name) Link to comment Share on other sites More sharing options...
rytek Posted August 26, 2013 Share Posted August 26, 2013 (edited) you have to change Meta class, go to the classes\Meta.php and look for function: (...) the most important thing in code above is a part below: $row['meta_title']=$row['meta_title']." ".$cat->name; $row['name'] - product name $cat->name - category name your tittle will looks like: "Macbook Laptops" Hi Vekia. I found an issue with this code. If i add anything to $row['meta_title'] variable, my meta title is empty. $row['meta_title']=$row['meta_title']." ".$cat->name; This code display only category name. Anyone know where is problem? Oh, i'm using prestashop 1.5.4 Thanks. Edited August 26, 2013 by rytek (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 26, 2013 Share Posted August 26, 2013 if you don't have anything in the meta title definition - the $row['meta_title'] will be empty - so in title also you will not see this value *because it is empty i don't know what you expect Link to comment Share on other sites More sharing options...
rytek Posted August 26, 2013 Share Posted August 26, 2013 (edited) Ok, but, if i keep original file, my title is like: $productName - $shopName. If i try to add something to $row['meta_title'], title will be empty. $row['meta_title'] .= "test"; result: test But, if i assign: $row['meta_title'] = $row['meta_title']; - title will be normally displayed. $row['meta_title']=$row['meta_title']." ".$cat->name; - only category name will be displayed. Edited August 26, 2013 by rytek (see edit history) Link to comment Share on other sites More sharing options...
tobto Posted November 11, 2013 Share Posted November 11, 2013 hi, Prestaguys )Could you tell me, please, how to do the same with 1.4? Should I copy Meta.php from a current version? Meta.php v.1.4 doesn't have function getProductMetas.Thanks! Link to comment Share on other sites More sharing options...
kodu1p Posted January 17, 2014 Share Posted January 17, 2014 Hello Vekia, thank you for your work.I have a problem with this, i was modify meta.php like in this article and when i reload site....white, i upload original meta.php, but same problem. moto-anvelope.ro What i need to do now, because i dont know. Thank you again.Codrin Link to comment Share on other sites More sharing options...
kodu1p Posted January 17, 2014 Share Posted January 17, 2014 Hello Vekia, thank you for your work. I have a problem with this, i was modify meta.php like in this article and when i reload site....white, i upload original meta.php, but same problem. moto-anvelope.ro What i need to do now, because i dont know. Thank you again. Codrin Solved, thank you. Link to comment Share on other sites More sharing options...
ppiultrasound Posted January 18, 2014 Share Posted January 18, 2014 Hey guys, I am trying to get this fixed and I can not figure it out. I attached the seo problems it keeps telling me. My website is www.ppiultrasound.com. One is my H1 tag can not be found and also my logo i believe is not <img> tag does not have an ALT attribute defined. Any help would be great. Thank you! Link to comment Share on other sites More sharing options...
vekia Posted January 19, 2014 Share Posted January 19, 2014 hello and how it's related to meta title, which is a main case in this topic? if you've got questions not related to this thread - please create new one. it will be much more visible then, and this will be helpful for whole community too thanks in afvane Link to comment Share on other sites More sharing options...
vekia Posted January 19, 2014 Share Posted January 19, 2014 Hello Vekia, thank you for your work. I have a problem with this, i was modify meta.php like in this article and when i reload site....white, i upload original meta.php, but same problem. moto-anvelope.ro What i need to do now, because i dont know. Thank you again. Codrin white page means that you probably changed something wrong Link to comment Share on other sites More sharing options...
kodu1p Posted January 19, 2014 Share Posted January 19, 2014 white page means that you probably changed something wrong Hi again, is still white, you can give me a solution? Yesterday went, today still not working, i dont now why. Link to comment Share on other sites More sharing options...
vekia Posted January 19, 2014 Share Posted January 19, 2014 sure, i can help turn on error reporting, this is the most important step in debug process and let me know what you see after that open config/defines.inc.php find this line: define('_PS_MODE_DEV_', false); change to look like this: define('_PS_MODE_DEV_', true); with regards, Milos Link to comment Share on other sites More sharing options...
kodu1p Posted January 19, 2014 Share Posted January 19, 2014 sure, i can help turn on error reporting, this is the most important step in debug process and let me know what you see after that open config/defines.inc.php find this line: define('_PS_MODE_DEV_', false); change to look like this: define('_PS_MODE_DEV_', true); with regards, Milos Huhh, i will, put below the errors, thank you. Warning: Function getDefaultCountryId() is deprecated in /home/rser1893/public_html/moto-anvelope.ro/modules/homecarousel/homecarousel.php on line 278 in /home/rser1893/public_html/moto-anvelope.ro/classes/Tools.php on line 2137 Notice: Undefined variable: category in /home/rser1893/public_html/moto-anvelope.ro/modules/homecarousel/homecarousel.php on line 340 Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file '/home/rser1893/public_html/moto-anvelope.ro/themes/default/./header.tpl' in '/home/rser1893/public_html/moto-anvelope.ro/themes/default/layout.tpl'' in /home/rser1893/public_html/moto-anvelope.ro/tools/smarty/sysplugins/smarty_internal_templatebase.php:127 Stack trace: #0 /home/rser1893/public_html/moto-anvelope.ro/tools/smarty/sysplugins/smarty_internal_template.php(286): Smarty_Internal_TemplateBase->fetch(NULL, NULL, NULL, NULL, false, false, true) #1 /home/rser1893/public_html/moto-anvelope.ro/cache/smarty/compile/76/f0/ef/76f0ef7e1fef534e5bd56f59c49b64ee1b075f22.file.layout.tpl.php(31): Smarty_Internal_Template->getSubTemplate('/home/rser1893/...', NULL, NULL, NULL, NULL, Array, 0) #2 /home/rser1893/public_html/moto-anvelope.ro/tools/smarty/sysplugins/smarty_internal_templatebase.php(180): content_52dc0adaac24d1_99242479(Object(Smarty_Internal_Template)) #3 /home/rser1893/public_html/moto-anvelope.ro/tools/smarty/sysplugins/ in /home/rser1893/public_html/moto-anvelope.ro/tools/smarty/sysplugins/smarty_internal_templatebase.php on line 127 Link to comment Share on other sites More sharing options...
vekia Posted January 20, 2014 Share Posted January 20, 2014 ok, so let me explain: Warning: Function getDefaultCountryId() is deprecated in /home/rser1893/public_html/moto- it's not an error, it's a prestashop internal message that homecarousel use deprecated functions. it doesn't affect website, it's just short information about that. nothing more. the same with notice message about undefined varialbe in homecarousel. problem is with fatal error. does the header.tpl file exist in your theme directory? Link to comment Share on other sites More sharing options...
kodu1p Posted January 20, 2014 Share Posted January 20, 2014 ok, so let me explain: it's not an error, it's a prestashop internal message that homecarousel use deprecated functions. it doesn't affect website, it's just short information about that. nothing more. the same with notice message about undefined varialbe in homecarousel. problem is with fatal error. does the header.tpl file exist in your theme directory? Vekia, thank you verry verry much for your work, i see the problem finaly, i have missing my header.tpl and product.tpl from directory, i resolved this, Question is why?, i used HTML Block from presta.eu , and made some modification at the template with this block, but today when i looked for this block in BO, surprise, it is no longer. I am only one who have acces in BO and CPanel. You have any ideea, or another that this problem? Thank you again. Link to comment Share on other sites More sharing options...
vekia Posted January 20, 2014 Share Posted January 20, 2014 i don't know what you exactly changed - everything depends on it 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