3 Replies Latest reply on Jun 4, 2018 9:02 AM 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
          • 2. Re: Facebook Buttons
            Efx

            Hi,

             

            I am using something similar with a custom facebook icon, here is my code:

             

            <a class="btn facebook" role="button" onclick="popupCenter('http://www.facebook.com/share.php?u=myurl.com?article_id=<cfoutput>#myquery.article_id#</cfoutput>', 'myPop1',650,350);" href="javascript:void(0);">

            <i class="icon-facebook"></i></a>

             

            I have the meta tags setup as above and they show up fine in the facebook debugger, however, when I try to share my page, it gives the default titles as if the meta tags have been bypassed.

             

            Is there a way to use a custom icon and have coldfusion use the set metatags when sharing.

            • 3. Re: Facebook Buttons
              stansell Level 1

              I don't know, this seems more of a Facebook question than a ColdFusion question.  If you do a view source on the page in your browser, do the meta tags appear to be formatted correctly?