Jump to content

[SOLVED] Changing Shop Name Title Position


megamulti

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

Link to comment
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

Link to comment
Share on other sites

  • 7 months later...

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:

Link to comment
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?

Link to comment
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
×
×
  • Create New...