Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Add Facebook Comments Using PHP Code
Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
Nov 17, 2016 - 12:55 pm

Wondering if there is a way to add Facebook comments in a post? Have done this in the past by using a plugin and pasting it's shortcode under a post.

Ditched the plugin and added fb-comments manually in my theme that works great. However i need to add this snippet in one of SimplePress template files to enable that function.

fbc.jpgImage Enlarger

Poked around in the reboot theme files but not sure which file or where in the file to add this. 

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 17, 2016 - 3:18 pm

Well - the correct template will be the Topic View (one in the Desktop folder and one in the Mobile folder).

But where exactly do you want to place this so I can be more precise?

Does it work by listening for the class (fb-comments)?

Oh - and you will have to change the href argument as well  but I can tell you what to use when I understand the location better.

andy-signature.png
YELLOW
SWORDFISH
Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
Nov 17, 2016 - 3:31 pm

It should be inserted right after the first post in the text area.  

It pulls a comment app from Facebook allowing fb members to comment and optionally post their comment to their fb profile with a link to visit the topic. 

I have it just above my blog post comments so either may be commented on. 

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 17, 2016 - 3:55 pm

Let's try this - although please remember I can not test this so anything could happen! Find the line of code in the topic view template(s) that corresponds to:

if (sp_has_posts()) : while (sp_loop_posts()) : sp_the_post();

and immediately after that and before the comment about starting the post section add the new bit in the following code:

if (sp_has_posts()) : while (sp_loop_posts()) : sp_the_post();
if ($spThisPost->post_index > 1) {
    echo ('<div class="fb-comments" data-href="'.$spThisTopic->topic_permalink.'" data-width="100%" data-numposts="10" data-order-by="social" data-colorscheme="light"></div>');
}

see of that works for you...

(Just in case - although I am sure you know - use the 'Raw Code' button and copy the code from the popup window.)

andy-signature.png
YELLOW
SWORDFISH
Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
Nov 18, 2016 - 9:48 am

Hi Andy, nope that didn't work.. Though i did see a big white space between several existing posts.

Assuming the ideal position would be in the 1st post content immediately after the text. That way anyone wanting to comment using their Facebook act could do so only in the 1st post. Other posts to the thread would be using the forum itself.

Probably a good idea for a SP plugin to add this functionality. Just need this snippete added to the head section.

fb-head.jpgImage Enlarger

Thanks again for your help.. wink

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 18, 2016 - 12:02 pm

So are you saying that supporting javascript is not being loaded by this plugin? Is that because the forum uses a page and the plugin only applies the script to WP posts?

Getting this into the header is no real problem but it still doesn't look to me like that is enough. There must be another component to this I would have thought.

andy-signature.png
YELLOW
SWORDFISH
Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
Nov 18, 2016 - 1:04 pm

All that is needed is those two snoppets, and creating the app on Facebook developers site. The app is connected to the sites domain. Don't matter if it's a post or page, just have to pull the post url. That could a problem with sp since it's not a wordpress standard permalink. 

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 18, 2016 - 3:07 pm

There should be no problem with the permalink - it is WP consistent and we passed it in the code I gave you yesterday.
How is that header code being put in place now?

andy-signature.png
YELLOW
SWORDFISH
Avatar
FidoSysop
Clearwater Florida
Member

VIP
sp_UserOfflineSmall Offline
Nov 18, 2016 - 3:19 pm

It's in my themes header file.. 

  • Doc ~ An old Fidonet SysOp. Just hanging out in cyberspace keeping up with tech.
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 18, 2016 - 3:24 pm

So it should be there for pages as well as posts. So no need to double it up. I still think there is something more. I don't see how the code from yesterday matches up with the code in your header...

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626