AbanteCart Community
Shopping Cart Operations => Support => General Support => Topic started by: kelbel3abh on December 11, 2014, 08:58:30 PM
-
Hey, there! I am needing to know the php that will pick up the main product image on each product pages, so that Facebook knows which pic to use for social sharing. Right now, when someone shares to FB, it picks up random images on the page.
Here is what I am trying to put in the head.tpl
Here is what I need:
<meta property="og:image" content="url_of_image" />
I have tried both of these:
<meta property="og:image" content="<?php echo $image_url; ?>" />
<meta property="og:image" content="<?php echo $image['main_url']; ?>" />
However, when I view source, it shows up like this, so it isn't picking up code:
<meta property="og:image" content="" />
-
Here is the controller for the product page:
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/pages/product/product.php
Head is processed by this controller
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/common/head.php
Check ADocument class to see how you can add to head from regular controller. You do not need to change head.php for this.
core/lib/document.php
-
Thanks for clarifying...
-
Thanks for the reply, but I am confused. I thought I could just put this in the head.tpl
<meta property="og:image" content="url_of_image" /> and I would just need the php to pick up the main product image. No?
-
For instance, this url:
<meta property="og:image" content="<?php echo $image_url; ?>" />
But the <?php echo $image_url; ?> doesnt seem to work.
-
I also tried this one:
<meta property="og:image" content="<?php echo $image_main; ?>" />
When I view source, it just shows: <meta property="og:image" content="" />
So, I am using the wrong thing, I guess. ??
Just to check, I used:
<meta property="og:image" content="<?php echo $base; ?>" />
and although that isn't what I need there, it did show up when I viewed the source code.
-
have you looked at the new version of Sharethis extension.
It seems to do what you want - it's a free extension in the marketplace
http://marketplace.abantecart.com/sharethis (http://marketplace.abantecart.com/sharethis)
just be sure you install 1.0.2.
-
Hi, thanks! I did try it a few days ago, but I see there is a new one. I did have the same problem with that one not picking up the correct pic. But, maybe now...
:) Will try it! -Kelly
-
This version does pick up the product images..yay!
I am just now trying to figure out how to change the text "Share to your Friends." Anyone have an idea?
-
Look in the System > Localizations > Language Definitions
then search the Key for
sharethis_share_text
There you can change it to whatever you would like.
Cheers,
Lee
-
Aha! Thanks so much, Lee!
-
Lee
I can't find the Sharethis_share_text key in the path you told.
what seems to be the reason ?
-
let me be sure you've gotten the correct version
the Share_This extension works with version 1.1.9 and earlier of AbanteCart. You seem to be new to the board so you maybe have the latest version which is 1.2.1. That may be your issue.
FYI, there will be a different "share" for 1.2. versions available in the near future - it will be Add-This.
Lee
-
Similar to links, I created an array metalinks and functions getmetalinks(), resetmetalinks() & addmetalink()
made the changes into:
document.php, head.php, head.tpl
I used $this->document->addMetaLink(array('property' => 'og:type', 'content' => 'product' )); in product.tpl and metalinks() values do not show on head.tpl ?