• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Facebook Buttons

Explorer ,
Dec 13, 2017 Dec 13, 2017

Copy link to clipboard

Copied

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

TOPICS
Advanced techniques

Views

682

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2018 May 27, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 04, 2018 Jun 04, 2018

Copy link to clipboard

Copied

LATEST

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation