freakystreak Posted September 2, 2013 Share Posted September 2, 2013 I have managed to get a custom page to work as I need. Has anyone been able to adapt the header.tpl page to allow for meta tags to be custom and not generated through the admin? I need to have custom meta tags for title, description and keywords. Searched through google and the forum here but can't seem to find someone who has attempted this or managed to do it. Thanks Link to comment Share on other sites More sharing options...
freakystreak Posted September 10, 2013 Author Share Posted September 10, 2013 Managed to solve this myself. If anyone wants to know how to do it then just let me know. Link to comment Share on other sites More sharing options...
Mando Posted September 10, 2014 Share Posted September 10, 2014 I'm interested by knowing how you did that, since I encounter the same issue and cannot solve it for the moment. Link to comment Share on other sites More sharing options...
Mando Posted September 11, 2014 Share Posted September 11, 2014 Since I had a stroke of genius last night, I found a solution, so I'll give it for whoever fells on this thread and needs a solution : You just have to modify the Tools class, and add at the end of the getMetaTags() function something like : For a fixed page : elseif(strpos($_SERVER['PHP_SELF'],'blog.php')) { $row = array(); $row['meta_title'] = 'My title - '.Configuration::get('PS_SHOP_NAME'); $row['meta_description'] = 'My meta_description'; $row['meta_keywords'] = 'My meta_tags'; return self::completeMetaTags($row, $row['meta_title'], $row['meta_description'], $row['meta_keywords']); } If these are dynamic pages (say, articles of the blog) : elseif ($id_article = self::getValue('id_article')) { $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT `post_meta_title`, `post_meta_description`, `post_meta_keywords` FROM `'._DB_PREFIX_.'my_blog` WHERE id_lang = '.(int)($id_lang).' AND id_pl_blog_post = '.(int)($id_article)); if ($row) { $row['meta_title'] = $row['post_meta_title'].' - Article from '.Configuration::get('PS_SHOP_NAME').'\'s blog'; $row['meta_description'] = $row['post_meta_description']; $row['meta_keywords'] = $row['post_meta_keywords']; return self::completeMetaTags($row, $row['meta_title'], $row['meta_description'], $row['meta_keywords']); } } And here we are, we can have meta_datas corresponding our pages, fixed or dynamics, and not default ones. Google likes it. Link to comment Share on other sites More sharing options...
Mecadisc Posted October 4, 2016 Share Posted October 4, 2016 (edited) Thanks So much guy You saved my life, if you want this work on 1.6 version you have to put it in Meta.php (classes Path). Have a nice day. Edited October 4, 2016 by Mecadisc (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