Jump to content

[solved] remove shop name added to meta title of pages


Recommended Posts

so Prestashop automatically adds shop name to meta title, wich I dont want.

 

With the controllers thing, i am very confused as of where and how fix that,

 

thanx for your help

 

you must edit Meta class, you can find there something like:

 

$row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');

 

you must delete the: Configuration::get('PS_SHOP_NAME'); from each meta_title value

 

it's better to override this class, than edit default file

Link to comment
Share on other sites

ok, if i get it, I go to /override/classes/Meta.php and copy there the relevant code from /classes from /classes/Meta.php:

 

public static function getHomeMetas($id_lang, $page_name)
   {
       $metas = Meta::getMetaByPage($page_name, $id_lang);
       $ret['meta_title'] = (isset($metas['title']) && $metas['title']) ? $metas['title'].' - '.Configuration::get('PS_SHOP_NAME') : Configuration::get('PS_SHOP_NAME');
       $ret['meta_description'] = (isset($metas['description']) && $metas['description']) ? $metas['description'] : '';
       $ret['meta_keywords'] = (isset($metas['keywords']) && $metas['keywords']) ? $metas['keywords'] :  '';
       return $ret;
   }

 

so in line 4 of the above snippet i just leave this:

 

$ret['meta_title'] = (isset($metas['title']) && $metas['title']) ? $metas['title'];

 

is this correct?

Link to comment
Share on other sites

is this correct?

 

in this case it's better to use code below:

 

$ret['meta_title'] = (isset($metas['title']) && $metas['title']) ? $metas['title']:'';

 

I tested it and it works well, hope it helps you :)

I will write step-by-step tutorial about that for other users.

Can i mark this topic as solved? please reply if it works.

Link to comment
Share on other sites

not yet, i'm quite noob at this php with classes

 

I tried this: copy pasted code inside 'original' Metacore class, then searched from all lines that appended shop name and deleted it. Maybe i made an error, but this didnt work.

 

Should I try just dropping your line in the now emptied again class class 'Meta extends MetaCore' in overrides?

Link to comment
Share on other sites

if you dont want to edit main class, you must override it. So - you must open override/classes/Meta.php file

 

and paste new function, that you want to override. here is an example that correspond to this case:

 

<?php
class Meta extends MetaCore
{
public static function getHomeMetas($id_lang, $page_name)
{
 $metas = Meta::getMetaByPage($page_name, $id_lang);
 $ret['meta_title'] = (isset($metas['title']) && $metas['title']) ? $metas['title'] : '';
 $ret['meta_description'] = (isset($metas['description']) && $metas['description']) ? $metas['description'] : '';
 $ret['meta_keywords'] = (isset($metas['keywords']) && $metas['keywords']) ? $metas['keywords'] :  '';
 return $ret;
}
}

Link to comment
Share on other sites

great thanks, vekia, got it with gethomemetas.

 

however, i am clueless as to how to strip just ps_shop name in this line in getcategorymetas() in line 30 of meta.php:

 

$row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');

 

as you see, im quite noob at this, i really appreciate your help

Link to comment
Share on other sites

  • 4 months later...
  • 4 months later...
×
×
  • Create New...