Solved

Cold Fusion Meta Tag and Open Graph

Posted on 2013-06-18
8
769 Views
Last Modified: 2013-06-19
Hi,
I'm having an issue with Facebook not pulling the correct photos to use as a thumbnail when someone shares one of the dynamic pages on my site.
I read on the FB site that I should use Open Graph (og) tags in a meta tag on my site.
So that's what I tried to do.
<cfset photoext =".jpg">            
<cfset finalphoto = #ID_Number# & photoext>
      
      <meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/#finalphoto#" />

However, whenever I check any of my pages using the Facebook debugger:
https://developers.facebook.com/tools/debug

It appears as though Facebook is not seeing the resolved value of #finalphoto# because the URL is says it scraped is:
http://www.mysite.com/site-data/photos/property/1/#finalphoto#
and not
http://www.mysite.com/site-data/photos/property/1/myphoto.jpg

If I hard code in a photo name in the meta tag then FB sees it just fine.
      <meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/hardcodephoto.jpg />

I created a log file using <cffile> and write the value of the meta tag to the log file and see that the generated URL/photo is completely valid.
I am not understanding why the value of #finalphoto# isn't being resolved by the facebook scraper.
Anyone have any ideas?

Thanks,
N
0
Comment
Question by:nachtmsk
  • 3
  • 3
  • 2
8 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39257408
I'm not familiar w/the FB debugger...  

As silly as it sounds, the only thing I can think of is that maybe you forgot to wrap the <meta> tag in a cfoutput, so the #finalphoto# variable is never evaluated. That's why FB sees "#finalphoto#" instead of "myphoto.jpg".


<cfset photoext =".jpg">            
<cfset finalphoto = ID_Number & photoext>
<cfoutput>      
      <meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/#finalphoto#" />
</cfoutput>
0
 

Author Comment

by:nachtmsk
ID: 39257682
Hi agx
The meta tags need to be in the HEAD element. I don't think I did wrap it in a cfoutput. Wondering if I can put a cfoutput tag in the HEAD element. I'll try and report back! Thanks!
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39257754
(Edit) Sure, you can use cfoutput anywhere.  It runs on the server, so the browser never even sees it. All it'll do is cause your #variable# to be evaluated, turning this HTML string:

<meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/#finalphoto#" />

... into this:

<meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/myphoto.jpg" />
0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 39257874
As a matter of fact, you can use  <cfhtmlhead> tag to create the meta tag,

Here is simple usage example.

<cfset photoext =".jpg">            
<cfset finalphoto = "YourPhoto" & photoext>

<h1>Thank You</h1>
<div>All of your coldfusion and html code goes here!</div>

<!--- Save the headcontent --->
<!--- This code can appear anywhere within your page --->
<cfsavecontent variable="headContent">
<cfoutput>
<meta property="og:image" content="http://www.mysite.com/site-data/photos/property/1/#finalphoto#" />
</cfoutput>      
</cfsavecontent>

<!--- Add the head content --->
<!---
Use this tag for embedding JavaScript/other HTML tags, such as meta, link, title, or base in an HTML page header
--->
<cfhtmlhead text="#headContent#"/>
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 52

Expert Comment

by:_agx_
ID: 39257910
Yeah, but the real problem had nothing to do with headers.  He just forgot the cfoutput tags.  You must use cfoutput tags to display the value of a variable, simple as that. Omit it and you just get literal code.

Test Code
        <cfset yourVariable = "FOO">
        no cfoutput: #yourVariable#
        with cfoutput <cfoutput>#yourVariable</cfoutput>

Output/Result


        no cfoutput: #yourVariable#
        with cfoutput: FOO
0
 

Author Comment

by:nachtmsk
ID: 39257926
Ugh.. can't believe I forgot the <cfoutput> tags . It was driving me nuts for a few hours.
Working fine now.
Thanks everyone!
Nacht
0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 39259176
What I was showing is a way to handle the content that should go inside a <head></head>
tag.
0
 

Author Comment

by:nachtmsk
ID: 39259323
Thanks Pravinasar. It's good to know how to handle that. I should have given you some points too, sorry.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
There are countless ways to use social media and often times businesses are not using it properly. Is your business making any social media mistakes? Here are some tips to get your foot in the door with social media and make the most of it for your …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now