Welcome to Geeklog Saturday, February 22 2020 @ 10:51 pm EST

Geeklog Forums

{return


Status: offline

gtgillis

Forum User
Full Member
Registered: 05/11/03
Posts: 121
Location:Spring, TX
confused
I am playing with Facebook comments to see how difficult it would be to create a plugin or add the functuionality to the SocialShare plugin. While testing I inserted a <div> and a portion of script into the header.thtml file and a <div> into the storytext.thtml file. When I view the page source I see that part of the script from the header.thtml file has been stripped out.

This is the code I inserted into the header.thtml file.
PHP Formatted Code

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=MY_FB_APP_ID";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
 


This is what I see when I view the source. As you can see it is missing the "{return;}" on the line four.
PHP Formatted Code

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id))
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=MY_FB_APP_ID";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
 


I guess I need to know how and why it is being stripped out and how I can work around it.


Regards,

Greg
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 14/01/05
Posts: 1569
Location:la rochelle, France
Hi,

add spaces around the brackets works. See here

Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

gtgillis

Forum User
Full Member
Registered: 05/11/03
Posts: 121
Location:Spring, TX
Thanks. That did the trick.



Quote by: ::Ben

Hi,

add spaces around the brackets works. See here

Ben

 Quote

All times are EST. The time is now 10:51 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content