Reputation: 11
I have a share to Facebook button on a page that displays obituaries.
This site is coded in ColdFusion. What I am trying to do is pass the obituarietitle
variable to the meta tag og:description
like so:
<meta property="og:description" content="#obituarietitle#">
Through using the https://developers.facebook.com/tools/debug/og/object/ everything is showing up except the description which would be the name of the person who has passed.
The "share" shows #obituarietitle#
the variable.I have tried cfoutput tags, cfsets, ect.
I am not seasoned with ColdFusion or og:, I don't know if this is possible.
Upvotes: 1
Views: 951
Reputation: 338168
You must be in a cfoutput region to write variable contents to the output HTML.
So this would work:
<cfoutput>
<meta property="og:description" content="#EncodeForHTMLAttribute(obituarietitle)#">
</cfoutput>
Note the EncodeForHTMLAttribute()
- calling this function is necessary to ensure that the value will not break your markup if it contains HTML-specific characters.
It is also a security precaution that prevents HTML injection. Make sure you use this function on all variable values that you output.
Edit: EncodeForHTMLAttribute()
is a cousin of the EncodeForHTML()
function, member of a group of functions designed to format ColdFusion values in such a way that they are suitable to be used safely in various contexts.
Upvotes: 3