Jump to content

[SOLVED] Changing Shop Name Title Position


megamulti
 Share

Recommended Posts

I want to change the position of the shop name title displayed in the browser on the left location above.
For example, When I fill in shop name "My Shop name" and go to SEO and URL and edit for example Authentication, then the result will be:

Authentication - My Shop name
But I want it to turn:
My Shop name - Authentication.

So that every browser title begins with My Shop name, instead of begining with the SEO name given.

Many thanks in advance

Share this post


Link to post
Share on other sites

Hi,

 

just override Meta::getHomeMates:

/**
 * Get meta tags for a given page
 *
 * @since 1.5.0
 * @param int $id_lang
 * @param string $page_name
 * @return array Meta tags
 */
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;
}

 

with this:

/**
 * Get meta tags for a given page
 *
 * @since 1.5.0
 * @param int $id_lang
 * @param string $page_name
 * @return array Meta tags
 */
public static function getHomeMetas($id_lang, $page_name)
{
 $metas = Meta::getMetaByPage($page_name, $id_lang);
 $ret['meta_title'] = (isset($metas['title']) && $metas['title']) ? Configuration::get('PS_SHOP_NAME').' - '.$metas['title'] : 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;
}

 

Regards

Share this post


Link to post
Share on other sites

  • 7 months later...

Hello all,

 

This is not working for my prestashop 1.5.5 for some reason the shopname dissapears from the title completely. I have all the caching off and force compilation on. I have no idea what i am doing wrong:(

 

Thank you in advance!

 

Jaivy

Share this post


Link to post
Share on other sites

Thank you for the responses! I finally managed to do it :rolleyes:

Now i am going to do it for my categories and products as well since it doesn't do it all together. :wacko:

Ill upload the file as soon as i am done. :D

 

vekia: This is my shop, beware tho, it's dutch and i sell 50 shades of grey kind of products :ph34r:

Share this post


Link to post
Share on other sites

Ok i think i spoke to soon.

 

The meta title in the products and category didn't add it at all, i forgot i have entered the shopname by hand. But still no automatic shopname.

public static function getCategoryMetas($id_category, $id_lang, $page_name, $title = '')
	{
		if (!empty($title))
			$title = ' - '.$title;
		$page_number = (int)Tools::getValue('p');
		$sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description`
				FROM `'._DB_PREFIX_.'category_lang` cl
				WHERE cl.`id_lang` = '.(int)$id_lang.'
					AND cl.`id_category` = '.(int)$id_category.Shop::addSqlRestrictionOnLang('cl');
		if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
		{
			if (empty($row['meta_description']))
				$row['meta_description'] = strip_tags($row['description']);

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

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

			return Meta::completeMetaTags($row, $row['name']);
		}

i have no idea what i am doing wrong:( in my php noobish opinion this should work right?

Share this post


Link to post
Share on other sites

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More