1 Reply Latest reply on Feb 9, 2018 12:19 PM by stansell

    Facebook Buttons

    wycks Level 1

      Hi,

       

      My website still uses coldfusion 8 so I hope I can get some help despite it being old.k

       

      I'd like to add facebook buttons to each of my blogs automatically.  I'm looking at the facebook for developers information and it says to fill in the form to create this code:

       

      <html>
      <head>
       
      <title>Your Website Title</title>
        
      <!-- You can use open graph tags to customize link previews.
        Learn more: https://developers.facebook.com/docs/sharing/webmasters -->

       
      <meta property="og:url"   content="https://www.your-domain.com/your-page.html" />
       
      <meta property="og:type"   content="website" />
       
      <meta property="og:title"   content="Your Website Title" />
       
      <meta property="og:description"   content="Your description" />
       
      <meta property="og:image"   content="https://www.your-domain.com/path/image.jpg" />
      </head>
      <body>

       
      <!-- Load Facebook SDK for JavaScript -->
       
      <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 = "https://connect.facebook.net/en_US/sdk.js#xfbml=1";
        fjs
      .parentNode.insertBefore(js, fjs);
       
      }(document, 'script', 'facebook-jssdk'));</script>

       
      <!-- Your like button code -->
       
      <div class="fb-like"
        
      data-href="https://www.your-domain.com/your-page.html"
        
      data-layout="standard"
        
      data-action="like"
        
      data-show-faces="true">
       
      </div>

      </body>
      </html>

       

       

      Can I use coldfusion code within that code and will it work across all my blogs?  I'm pretty sure I know what kind of coldfusion code I have to add in there provided that it is possible to add coldfusion code within the above.  I could just go ahead and try it myself but I don't want it messing up and show up messed up on people's facebook if i've done it wrong.

       

      Thanks,

      Michael

        • 1. Re: Facebook Buttons
          stansell Level 1

          You can insert ColdFusion tags in that code.  Just use <cfoutput> </cfoutput>  around variables you want to insert into the code.

           

           

          Also, be conscious of the # in the URL of the Facebook code in the line:
          js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1";

          If that gets surrounded by the <cfoutput> tag, it will throw an error due to ColdFusion thinking "#xfbml" is a syntax error. 
          To prevent that, you can use ##xfbml and the ## will be rendered on the page as a single #.  But that is only if that line is inside a <cfoutput> tag.

          1 person found this helpful