Jump to content

Solved: Adding variable to meta description


Recommended Posts



I couldn't find what I was looking for in the search.


I want to know how to add a variable to the meta description of categories.

For instance to add {SHOP} in the meta description, so that the shop name will appear.


I know how to add a variable to the regular category description:

if (isset($this->category)){

But this doesn't work when I do it for the meta description.


Does anyone know how to do it? It's useful if you want to mention your store name in the Meta description when you're using multistore.




Edited by Christiaan_01 (see edit history)
Link to comment
Share on other sites

Got it solved. Find the file frontcontroller.php


on line 290 delete this code

$this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name)

and paste this piece of code

// Start Custom: Replace {SHOP}
		// Original:
		// $this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name));
		$temp_metas = Meta::getMetaTags($this->context->language->id, $page_name);
		if ($temp_metas != null) {
			foreach ($temp_metas as $meta_key => $meta_value) {
				$temp_metas[$meta_key] = str_replace("{SHOP}", configuration::get('PS_SHOP_NAME'), $meta_value);
		} else {
			$this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name));
		// End Custom
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...