-1

I have a little knowledge of HTML and recently had a store built with PHP for our website. It works great but was expensive and have no money to pay for a little customization regarding a little issue I am experiencing so I am trying to fix it my self.

We want to share a product on Facebook but when we do it displays the page title and not the product or its description. I have looked around the internet for the issue and thought this was the way forward:

http://www.daddydesign.com/wordpress/how-to-create-a-custom-facebook-share-button-for-your-iframe-tab/

I got this working, so I tried to customize the code from that page to display the information I need from the PHP tags used on the page but as you can tell, I got nowhere.

<?php
$title=urlencode('<?php echo $value['product_name']; ?>');
$url=urlencode('http://mydomain.com');
$summary=urlencode('<?php echo $value['product_description']; ?>');
$image=urlencode('<?php if (is_null($value['product_image'])): ?>');
?>

The cart template is all .tpl so I have tried to put this in the header.tpl.

Edit:

I have been working on this for a while and got nowhere fast so I started to mess around with the link instead I got it working apart from the description has

in it how do I remove that tag? < p >

Edited Code:

<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=<?php echo $value['product_name']; ?> - only  <?php echo price($value['product_price']); ?>!&amp;p[summary]=<?php echo $value['product_description']; ?>&amp;p[url]=http://www.mydomain.com/store&amp;p[images][0]=<?php echo config_item('cart', 'site_url'); ?>uploads/images/<?php echo $value['product_image']; ?>','sharer','toolbar=0,status=0,width=548,height=325');" href="javascript: void(0)">Insert text or an image here.</a>
Community
  • 1
  • 1
Rick Skeels
  • 513
  • 1
  • 11
  • 30
  • Is there a list of products on page with each having share button, or is share button located on a page dedicated to each product? – Darvex Aug 13 '13 at 10:53
  • i have since found a walk around for this i am using the hyper link instead. but need to fix the < p > tag issue ill update my question – Rick Skeels Aug 13 '13 at 11:12

1 Answers1

1

Before adding the link, try this:

<?php
$tags = array('<p>','</p>');
$cleanDescription = str_replace($tags,'',$value['product_description']);
?>

It will remove any

tags from description. After that, in your link use $cleanDescription instead of $value['product_description']

Darvex
  • 3,624
  • 2
  • 23
  • 39