creation-handicap Posted June 7, 2016 Share Posted June 7, 2016 hello! i want to have individual meta tags per page. so i need to know on which page i am. how can i achieve that? for the product page i want to write the product description in the meta tag. somebody know how i can do that? Link to comment Share on other sites More sharing options...
creation-handicap Posted June 7, 2016 Author Share Posted June 7, 2016 (edited) i've found some vars i can use in the header.tpl: {$page_name} and like that i can see the category ID: {if $smarty.get.id_category} {$id_category = $smarty.get.id_category} {else} {$id_category = $product_id_category} {/if} only thing i did not yet achieve is getting the product description... question is, how can i get the var {$product} in my header.tpl? if it would be there, i could take this one {$product->description_short} and put it as meta description tag. Edited June 7, 2016 by creation-handicap (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted June 8, 2016 Share Posted June 8, 2016 What version of PrestaShop are you using? I just checked my PrestaShop v1.6.1.5 test site and it already uses the product's short description as the meta description if none is specified. It's on lines 261-262 of classes/Meta.php: if (empty($row['meta_description'])) { $row['meta_description'] = strip_tags($row['description_short']); Link to comment Share on other sites More sharing options...
creation-handicap Posted June 13, 2016 Author Share Posted June 13, 2016 I'm using prestahsop 1.4.9 Link to comment Share on other sites More sharing options...
rocky Posted June 13, 2016 Share Posted June 13, 2016 In that case, you'll have to create override/classes/FrontController.php with the following: <?php class FrontController extends FrontControllerCore { public function displayHeader() { parent::displayHeader(); if (Tools::getValue('controller') == 'product' && (int)Tools::getValue('id_product')) { $product = new Product((int)Tools::getValue('id_product'), false, (int)Tools::getValue('id_lang')); if (Validate::isLoadedObject($product)) { self::$smarty->assign('meta_description', $product->description_short); } } } } This should override the {$meta_description} variable in header.tpl with the product's short description if it is available. I haven't tested this code though, so you'll have to test it yourself. Link to comment Share on other sites More sharing options...
creation-handicap Posted June 13, 2016 Author Share Posted June 13, 2016 woaps! i did not check {$meta_description} before. seems it's already there without changing the FrontController.php. Thanks for your help! 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