Adding a facebook share link to each product

Silencer116

Avatar: Silencer116

2011-05-12 00:43

Hi everyone,

I looked everywhere, but I couldn't find a solution, so I'll ask here;

Does anyone knows how to create a variable share link for each product; so
I can have a share link to facebook? I know the like button, but I prefer the share link;

So what I want is to insert a link like this:
http://www.facebook.com/sharer.php?u=$url&t=$title

As it says; I need to know the complete url of a product. Now in my quickcart; the url is based on the product name.

Basically; These are my questions:
- Where can I put this link (in what file)
- How can I generate the complete/correct url?

Thanks in advance.

» Quick.Cart v4.x

korekkorek

Avatar: korekkorek

2011-05-12 16:26

wstawiasz link do pliku:

templates/products_default.tpl

i po kłopocie

beholder

Avatar: beholder

2011-05-13 01:50

The URL without the http://www.yoursite.com/ prefix should be the variable $aData[sLinkName]. But it changes depending on the context (template block) it is used in.
This won't help you though as you need a complete link, so you should put before it the full path to the QC webshop like this:
http://www.yoursite.com/shop/$aData[sLinkName]

Do let me know how this works, because if not, other users may get confused.

http://cicmanec.sk/easyplugins/

Silencer116

Avatar: Silencer116

2011-05-14 15:18

Beholder, where do I post this link?

beholder

Avatar: beholder

2011-05-16 03:41

Well, I am actually asking you where you want it to be. It could be one of these:
pages_default.tpl
products_default.tpl

..depending on where you want the share link to appear.

http://cicmanec.sk/easyplugins/

Silencer116

Avatar: Silencer116

2011-05-16 15:02

Haha, ok! Well I want it to be shown both on the product page, and on the product results page.

the exact location, I guess is just below the product.

Silencer116

Avatar: Silencer116

2011-06-24 10:10

Unfortunately, I still don't understand where I should put the link. Should it look like this?

http://www.facebook.com/sharer.php?u=http://www.yoursite.com/shop/$aData[sLinkName]

So I want to place this link on the product page.
I also want to place this link on a products list page.

beholder

Avatar: beholder

2011-06-24 13:24

Hi, so put it in both pages_default.tpl and products_default.tpl, not sure about specific locations but it must be LIST blocks. In case you can't figure it out, I'll have a look into the sources.

http://cicmanec.sk/easyplugins/

Silencer116

Avatar: Silencer116

2011-07-12 11:57

Thank you beholder, it works like a charm. I placed it at the product description at the pages_default.tpl and in de product div at products_default.tpl. Great! Thanks a lot.

grzdak

Avatar: grzdak

2011-10-11 19:16

beholder jak powinien wyglądać ten link? czy dokładnie tak:
http://www.facebook.com/sharer.php?u=http://www.mojadomena.pl/$aData[sLinkName]
kiedy wstawiam ten link w pliku product_default.tpl w divie content, ale jedyny efekt to pojawienie się treści linku na stronie produktu. Co poprawić?
pozdrawiam
G

grzdak

beholder

Avatar: beholder

2011-10-12 02:28

Grzdak> if you can't speak EN, use http://translate.google.com , so I understand you better.
Did you put the link to the correct place in pages_default.tpl or products_default.tpl?? It's the block PRODUCTS_LIST in pages_default.tpl or CONTAINER in products_default.tpl.

You can't do this in admin, you have to use FTP to directly edit files, of course.

http://cicmanec.sk/easyplugins/

grzdak

Avatar: grzdak

2011-10-12 09:13

Hi beholder, yes I do speak EN, sorry - just thouht you're polish :) don't now why.....
The problem was not where to put it, but what exactly put there.
from FB I received 2 parts of code:
- javascript sdk
- code with the link described above
I know that code with link I shoud put to both files mentioned above, but where to put the JS part - just before link in both files?

G

grzdak

beholder

Avatar: beholder

2011-10-12 16:52

I don't think you need any JS for this. When someone clicks the link, JS loads from FB page.

So as long as the link is correctly generated then it should be ok. Well, easy to try, just click the link that was generated on some of your pages.

http://cicmanec.sk/easyplugins/

alidj24

Avatar: alidj24

2013-02-21 15:48

For like button



<script type="text/javascript">
   document.write ('<iframe src="http://www.facebook.com/plugins/like.php?href='+window.location+'&layout=standard&show_faces=false&width=160&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:400px; height:40px"><\/iframe>');




For distribution button


   document.write ('<iframe src="http://www.facebook.com/plugins/like.php?href='+window.location+'&layout=standard&show_faces=false&width=160&action=recommend&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:400px; height:40px"><\/iframe>');
</script>
   <?php

Back to top
about us | contact