Topic: How to add tags Open Graph in between <head> tags?
I would like the title of the article to appear in the og: title tag, and the content fragment in the og: description tag. How to do it?
Dear CuteNews Users! Please feel free to contact us via our new Feedback Form and please send information about bugs to our bug tracker.
You are not logged in. Please login or register.
CutePHP Forums → Problem Solving / Help & Support → How to add tags Open Graph in between <head> tags?
I would like the title of the article to appear in the og: title tag, and the content fragment in the og: description tag. How to do it?
To do this, use some of the built-in API CuteNews tools. At first, add the strings below to the very beginning of the file, which contains the code <head>,
require_once("cn_api.php");
$entry = cn_api_get_entry();
Then, you can use such strings as
if ($entry) {
echo '<meta property="og:title" content="'.htmlspecialchars($entry['t']).'" />';
echo '<meta property="og:description" content="'.htmlspecialchars(substr($entry['s'], 0, 100)).'" />';
}
Thanks.
How to do it for photos?
Could you, please, specify the photo source? Will the photo be inserted into the additional field or wil it be extracted from the text?
In the first case, you just need to use $entry['mf']['the additional field name'], for example
echo '<meta property="og:image" content="'.htmlspecialchars($entry['mf']['myimage']).'" />';
myimage is the field name here.
I add photos to the server on which I have a website, then I add a link to the photo in the article.
To do this, you should use additional fields to insert a photo there.
To add a new field, go to Dashboard> Additional fields, select the type 'Image / Resource', the og_image name, for example. Then click 'Add / Replace field'.
When editing the news, a new og_image field will appear, with which you can select an image for the article. Then, as in the previous case, you can add this string to the <head> section
if (! empty ($ entry ['mf'] ['og_image']))) echo '<meta property = "og: image" content = "'. $ entry ['mf'] ['og_image']. '" /> ';
Open Graph meta tags should always be nested between <head> tags.
To turn your web pages into graph objects, you need to add basic metadata to your page. We've based the initial version of the protocol on RDFa which means that you'll place additional <meta> tags in the <head> of your web page.
To do this, you should use additional fields to insert a photo there.
To add a new field, go to Dashboard> Additional fields, select the type 'Image / Resource', the og_image name, for example. Then click 'Add / Replace field'.
When editing the news, a new og_image field will appear, with which you can select an image for the article. Then, as in the previous case, you can add this string to the <head> section
if (! empty ($ entry ['mf'] ['og_image']))) echo '<meta property = "og: image" content = "'. $ entry ['mf'] ['og_image']. '" /> ';
This don't work. "Parse error: syntax error, unexpected 'entry' (T_STRING), expecting variable (T_VARIABLE) or '$' in /usr/home/news.php on line 15"
Did I paste well?
Please use this code string:
if (!empty($entry['mf']['og_image'])) echo '<meta property="og:image" content="'.$entry['mf']['og_image'].'" />';
Thanks a lot, it works.
Adding Open Graph to web pages This involves adding tags within the section of the page HTML code. Syntax This tag allows the use of two attributes which include property and content. TellCulvers.com
CutePHP Forums → Problem Solving / Help & Support → How to add tags Open Graph in between <head> tags?
Powered by PunBB, supported by Informer Technologies, Inc.
The pun_antispam official extension is installed. Copyright © 2003–2009 PunBB.