1

I'm using Magento CE 1.9 and I just tried to share a product on facebook. Worked like a charm except all the css of the text block was included :(

Can someone point me in the right direction as to how to fix this? Thanks.

Attached: Screenshot of problem.

enter image description here

2 Answers 2

1

I guess that you have send descrition

Used $this->htmlEscape() for you variable to remove html tag from string 

http://www.w3schools.com/php/func_string_strip_tags.asp

Edit: change

urlencode(trim($_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description')));

to

urlencode(trim($this->htmlEscape($_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description'))));

Edit:use basic php function strip_tags to remove all html tag from string

 urlencode(trim( strip_tags($_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description'))));
9
  • Which file should I edit this in? Sorry but I am not very familiar with Magento. Thanks.
    – sarovarc
    Commented Sep 1, 2014 at 5:59
  • app\design\frontend\yourpackage\yourtemplate\template\catalog\product\view\sharing.phtml
    – Amit Bera
    Commented Sep 1, 2014 at 6:10
  • That didn't work :/
    – sarovarc
    Commented Sep 1, 2014 at 6:28
  • I changed the following line to: <?php $_u = 'p[url]=' . $_productUrl . '&p[images][0]=' . $_productImageUrl . '&p[title]=' . $_productName . '&p[summary]=' . urlencode(trim($_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description'))); ?> TO: <?php $_u = 'p[url]=' . $_productUrl . '&p[images][0]=' . $_productImageUrl . '&p[title]=' . $_productName . '&p[summary]=' . urlencode(trim($_helper->productAttribute($_product, nl2br($this->htmlEscape($_product->getShortDescription())), 'short_description'))); ?>
    – sarovarc
    Commented Sep 1, 2014 at 6:29
  • is it not work?
    – Amit Bera
    Commented Sep 1, 2014 at 6:43
0

Not sure if this still requires an answer however your problem is because you have not implemented Facebook's OpenGraph Tags...If more information is required please reply here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.