本文整理匯總了PHP中SiteTree::MarkupOpenGraph方法的典型用法代碼示例。如果您正苦於以下問題:PHP SiteTree::MarkupOpenGraph方法的具體用法?PHP SiteTree::MarkupOpenGraph怎麽用?PHP SiteTree::MarkupOpenGraph使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SiteTree
的用法示例。
在下文中一共展示了SiteTree::MarkupOpenGraph方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updateMetadata
/**
* @name updateMetadata
*
* Updates metadata with icons.
*
* @param SiteConfig $config
* @param SiteTree $owner
* @param $metadata
* @return void
*/
public function updateMetadata(SiteConfig $config, SiteTree $owner, &$metadata)
{
// decode into array
$data = json_decode($owner->OpenGraphData, true);
// check for data or throw an error
if ($data) {
// check if off
if ($data['og:type'] !== 'off') {
// Header
$metadata .= $owner->MarkupComment('Open Graph');
// Type
$metadata .= $owner->MarkupOpenGraph('og:type', $data['og:type']);
// URL
$metadata .= $owner->MarkupOpenGraph('og:url', $owner->AbsoluteLink());
// Site Name
$siteName = $data['og:site_name'] ? $data['og:site_name'] : $config->Title;
$metadata .= $owner->MarkupOpenGraph('og:site_name', $siteName, true);
// Title
$title = $data['og:title'] ? $data['og:title'] : $owner->Title;
$metadata .= $owner->MarkupOpenGraph('og:title', $title, true);
// Description
$description = $data['og:description'] ? $data['og:description'] : $owner->GenerateDescription();
$metadata .= $owner->MarkupOpenGraph('og:description', $description, true);
// Image
if ($owner->OpenGraphImage()->exists()) {
$metadata .= $owner->MarkupOpenGraph('og:image', $owner->OpenGraphImage()->getAbsoluteURL());
}
} else {
// OFF
$metadata .= $owner->MarkupComment('Open Graph [ off ]');
}
} else {
// ERROR
$metadata .= $owner->MarkupComment('Open Graph [ error ]');
}
}
開發者ID:graphiques-digitale,項目名稱:silverstripe-seo-open-graph,代碼行數:46,代碼來源:SEO_OpenGraph_SiteTree_DataExtension.php