Adding Facebook "Like" Button

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Adding Facebook "Like" Button

Post by Thorsten »

Hi,

ah, sorry... you're using phpMyFAQ 2.5. Please add in the file artikel.php at line 237 after the DiggIt! link the following code:

Code: Select all

// Build Facebook URL
$facebookUrl = sprintf('%s?cat=%s&id=%d&lang=%s',
    PMF_Link::getSystemUri(),
    $currentCategory,
    $record_id,
    $lang);
Then it will work.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
cozbaldwin2
Posts: 19
Joined: Thu Apr 22, 2010 3:26 pm

Re: Adding Facebook "Like" Button

Post by cozbaldwin2 »

Hallelujah.
It's working. Thanks so much for your time and help.

I hope there will be others out there who can benefit from this trouble-shooting.
Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Adding Facebook "Like" Button

Post by Thorsten »

Great! :-)

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
cozbaldwin2
Posts: 19
Joined: Thu Apr 22, 2010 3:26 pm

Re: Adding Facebook "Like" Button

Post by cozbaldwin2 »

Follow up question...

When one clicks on this, it will show up in their Facebook feed as (in my case): "Coz recommends HITS FAQ." but it's not including the question within the title. Facebook does provide some Metadata code but I'm not able to figure out how to pass along the title with question.

I'm putting this in the index.tpl
<meta property="og:title" content="{metaTitle}"/> which correctly passes the title of the FAQ without the question.

So I tried...
<meta property="og:title" content="{metaTitle} - {writeThema}"/> I was hoping this would work, but it does not.
I also tried {itemTitle} and {getRecordTitle} but they didn't seem to work either.

Any ideas?
Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Adding Facebook "Like" Button

Post by Thorsten »

Hi,

I think you have to move the <meta> tags to index.tpl.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
cozbaldwin2
Posts: 19
Joined: Thu Apr 22, 2010 3:26 pm

Re: Adding Facebook "Like" Button

Post by cozbaldwin2 »

Thorsten wrote:Hi,

I think you have to move the <meta> tags to index.tpl.

bye
Thorsten
I have them in index.tpl
cozbaldwin2
Posts: 19
Joined: Thu Apr 22, 2010 3:26 pm

Re: Adding Facebook "Like" Button

Post by cozbaldwin2 »

When comparing the DiggIt and Facebook URL builders, I was hoping I came across the solution when I noticed the Facebook one didn't have "title=%s" like the DiggIt one does:

Code: Select all

// Build Digg it! URL
$diggItUrl = sprintf('%s?cat=%s&id=%d&lang=%s&title=%s',
    PMF_Link::getSystemUri(),
    $currentCategory,
    $record_id,
    $lang,
    urlencode($thema));

// Build Facebook URL
$facebookUrl = sprintf('%s?cat=%s&id=%d&lang=%s',
    PMF_Link::getSystemUri(),
    $currentCategory,
    $record_id,
    $lang);


But it didn't matter. When I added it into the Facebook sprintf(), all it did was cause an error when loading the page.
*** phpMyFAQ warning [2]: sprintf() [function.sprintf]: Too few arguments in artikel.php on line 241. ***
So I was wrong, but maybe I am on to something, here?
Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Adding Facebook "Like" Button

Post by Thorsten »

Hi,

the DiggIt! URL is different to the Facebook one. That's the reason why you got the error message.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
cozbaldwin2
Posts: 19
Joined: Thu Apr 22, 2010 3:26 pm

Re: Adding Facebook "Like" Button

Post by cozbaldwin2 »

Ive been hoping someone else chimes in with the same problem but apparently no one else is trying to use the Like button with phpmyFAQ.

So -- the problem I was having still exists. The button is working but all it's sending over is the Index page title in my FAQ directory. I would like this to work properly by passing the page title (the Question) onto Facebook too -- so instead of the result being "Coz recommends HITS FAQ" and link to the specific FAQ article, it would say "Coz recommends 'Who sings this song?' on hiddeninthesand.com" like it does for every other website.
Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Adding Facebook "Like" Button

Post by Thorsten »

Hi,

we start the development of phpMyFAQ 2.7 soon and the Facebook "Like" button will be on our todo list. :-)

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
cozbaldwin2
Posts: 19
Joined: Thu Apr 22, 2010 3:26 pm

Re: Adding Facebook "Like" Button

Post by cozbaldwin2 »

That's wonderful news. A smart move.

But, I take it this means there is nothing you can do for me now, with version 2.5....?
Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Adding Facebook "Like" Button

Post by Thorsten »

Hi,

I'll take a deeper look at FB Like the next days. Please stay tuned.

btw, 2.5 will be out of support after the 2.7 release.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply