Jump to content

Recommended Posts

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

  • 1 year later...

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

  • 2 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...