Hi all!
I have implemented facebook like button on my site as example in this link (post # 14)
Implementation of the Facebook Like button on each product page - General Questions - CS-Cart Community Forums
The script works correctly.
What I do not know how to do:
To show my first product thumbnail of the picturec on the wall in facebook
To put the product name as the title on facebook
I think something should be added meta.tpl but do not know what.
Please help me!
Does anyone know how to do?
flow
October 24, 2011, 12:00am
3
It should do this automatically. If it doesn't you probably have an override hook of the meta file somewhere. Are you using other add-ons?
My version of cs-cart dont have the addon for facebook. I installed the "like button" after the example of this link: http://forum.cs-cart...h-product-page/ I use SEO URL addon. I don
t know how to write the image path in the content an the title path
I put this in meta.tpl between the {hook name=“index:meta”}{/hook}
I finally got this to work! I run CS-Cart 2.2.4, this is how i did it:
Get an App-ID from Facebook for your Facebook-site.
Add this code to your blocks/product_templates/default_template.tpl first of all, fill it in with correct ID & Domain:
<br />
{* $Id: default_template.tpl 12442 2011-05-12 12:45:40Z 2tl $ *}<br />
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#"> </html><br />
{script src="js/exceptions.js"}<br />
<div id="fb-root"></div><br />
<br />
{literal}<script> <br />
window.fbAsyncInit = function() {<br />
FB.init({<br />
appId : 'XXXXXXXXXXX', // App ID<br />
channelUrl : '//WWW.YOURDOMAIN.COM/channel.html', // Channel File<br />
status : true, // check login status<br />
cookie : true, // enable cookies to allow the server to access the session<br />
xfbml : true // parse XFBML<br />
});<br />
// Additional initialization code here<br />
};<br />
// Load the SDK Asynchronously<br />
(function(d){<br />
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}<br />
js = d.createElement('script'); js.id = id; js.async = true;<br />
js.src = "//connect.facebook.net/en_US/all.js";<br />
d.getElementsByTagName('head')[0].appendChild(js);<br />
}(document));<br />
</script> {/literal}<br />
```<br />
<br />
<br />
3. Put this code where you want to show the buttons, I used AddThis above my product title, you can get your own code from there, fill in your script code.<br />
<br />
```php
<br />
<!-- AddThis Button BEGIN --><br />
<div class="addthis_toolbox addthis_default_style "><br />
<a class="addthis_button_facebook_send" fb:send:width="200" style="opacity:1"></a> <br />
<a class="addthis_button_facebook_like" fb:like:layout="button_count" style="opacity:1"></a><br />
<a class="addthis_button_tweet"></a><br />
<a class="addthis_button_google_plusone" g:plusone:size="medium"></a><br />
<br />
<br />
</div><br />
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xxxxxxxxx"></script><br />
<!-- AddThis Button END --><br />
<br />
```<br />
<br />
4. I put this code in customer/index.tpl, line 3:<br />
```php
<html xmlns="http://www.w3.org/1999/xhtml" lang="{$smarty.const.CART_LANGUAGE|lower}" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"><br />
```<br />
<br />
5. This is how my customer/meta.tpl is looking atm, fill in your APP-ID:<br />
```php
{* $Id: meta.tpl 11825 2011-02-11 16:36:26Z zeke $ *}<br />
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#"> </html> <br />
{if $smarty.request.product_id == $product.product_id}{if $product.main_pair.icon.http_image_path}<br />
{assign var="http_image_path" value=http://`$config.http_host``$product.main_pair.icon.http_image_path`}<br />
{elseif $product.main_pair.detailed.http_image_path}<br />
{assign var="http_image_path" value=http://`$config.http_host``$product.main_pair.detailed.http_image_path`}<br />
{else}<br />
{assign var="http_image_path" value=http://`$config.http_host``$config.no_image_path`}<br />
{/if}<br />
{hook name="index:meta"}<br />
{if $display_base_href}<br />
<base href="{$config.current_location}/" /><br />
{/if}<br />
<meta http-equiv="Content-Type" content="text/html; charset={$smarty.const.CHARSET}" /><br />
<meta http-equiv="Content-Language" content="{$smarty.const.CART_LANGUAGE|lower}" /><br />
<meta name="description" content="{$meta_description|html_entity_decode|default:$location_data.meta_description}" /><br />
<meta name="keywords" content="{$meta_keywords|default:$location_data.meta_keywords}" /><br />
<meta property="og:image" content="{$http_image_path}" /><br />
<meta property="fb:app_id" content="XXXXXXXXXX" /><br />
{/hook}<br />
{/if}
```<br />
<br />
Here you can see how it looks:<br />
[url="http://rockalicious.se/dam/smycken/ringar/lejonring-med-stenar.html"]http://rockalicious....med-stenar.html[/url]<br />
<br />
You can check here if its working ok with the picture:<br />
[url="https://developers.facebook.com/tools/debug"]https://developers.f...com/tools/debug[/url]<br />
<br />
There might be some unnecessary code somewhere, im no professional <img src="upload://6j4WBaIkh87XQWLgsfZeyVm9COz.png" class="bbc_emoticon" alt=":P"> Good luck!