Jump to content

How to get image related to a product in the header for Google +1 "meta itemprop" tag


alexidro

Recommended Posts

According to the Google +1 snippet cutomization, I was wondering ho to get the cover image of a product to insert a "meta itemprop" tag in the header.tpl of my theme.

 

I wrote the following in the header.tpl, but don't works:

 

<meta itemprop="image" content="{if $page_name == 'product'}{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large')}{else}http://www.filateliaduetorri.com/images/filatelia2torri.jpg{/if}">

 

In the rendered page I get:

<meta itemprop="image" content="http://127.0.0.1/filatelia2torri/img/p/-large.jpg">

instead of:

<meta itemprop="image" content="http://127.0.0.1/filatelia2torri/img/p/3/7/37-large.jpg">

 

Where is the error?

 

Any help is really appreciated

Link to comment
Share on other sites

  • 4 months later...

Try this post!

[sOLVED] Load category name and product name in header

 

You'll need to add the following code in header.php before the $smarty->display:

if ($page_name == 'category' AND isset($_GET['id_category']))
{
  $category = new Category($_GET['id_category'], intval($cookie->id_lang));[/size][/font][/color]
[color=#000000][font=Verdana, sans-serif][size=3]   if (Validate::isLoadedObject($category))
  $smarty->assign('category_name', $category->name);
}
elseif ($page_name == 'product' AND isset($_GET['id_product']))
{
  $product = new Product($_GET['id_product'], false, intval($cookie->id_lang));[/size][/font][/color]
[color=#000000][font=Verdana, sans-serif][size=3]   if (Validate::isLoadedObject($product))
  $smarty->assign('product_name', $product->name);
}

 

then you can add the following to header.tpl:

{if isset($category_name)}{$category_name}{elseif isset($product_name)}{$product_name}{else}{l s='Hi something'}{/if}
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...