AH 增加结构化标签:文章、面包屑

hotfix/paypal-note
LiaoYijun 4 years ago
parent 2a41c674a6
commit adc2aa4cf1

@ -1148,11 +1148,26 @@ class Information extends CI_Controller
$breadcrumb_data = $this->Information_model->get_path_exclude_self($information->is_id, $information->is_path);
$ads_by_google = !empty(get_meta($information->ic_id, 'meta_google_ad_article'));
$data['ads_by_google'] = $ads_by_google;
$data['author'] = $this->Operator_model->get_author_nikename($information->ic_author); //获取作者信息
$author = $this->Operator_model->get_author_nikename($information->ic_author); //获取作者信息
$data['author'] = $author;
$data['breadcrumb_data'] = $breadcrumb_data;
$template_H1 = $this->load->view($template_path . '-h1', $data, TRUE);
$template = str_replace('<!--@HEAD_1@-->', $template_H1, $template);
// 结构化标签Article
$article_structured_data_content = $this->load->view(
$template_path . '-structured-data-article',
array('information' => $information, 'author' => $author),
true);
$template = str_replace('<!--@STRUCTURED-DATA-ARTICLE-BLOCK@-->', $article_structured_data_content, $template);
// 结构化标签BreadcrumbList
$breadcrumb_structured_data_content = $this->load->view(
$template_path . '-structured-data-breadcrumb',
array('breadcrumb_data' => $breadcrumb_data, 'information' => $information),
true);
$template = str_replace(
'<!--@STRUCTURED-DATA-BREADCRUMB-BLOCK@-->',
$breadcrumb_structured_data_content,
$template);
//推荐信息或者产品
//信息推荐

@ -401,6 +401,7 @@
}
}
</script>
<!--@STRUCTURED-DATA-BREADCRUMB-BLOCK@-->
<!--@STRUCTURED-DATA-ARTICLE-BLOCK@-->
</body>
</html>

@ -0,0 +1,28 @@
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://www.asiahighlights.com<?php echo $information->ic_url; ?>"
},
"headline": "<?php echo $information->ic_seo_title; ?>",
"image": [
"https://images.asiahighlights.com<?php echo $information->ic_photo; ?>"
],
"datePublished": "<?php echo $information->is_datetime; ?>",
"dateModified": "<?php echo date('Y-m-d\TH:i:s'); ?>",
"author": {
"@type": "Person",
"name": "<?php echo $author->OPI_FirstName; ?>"
},
"publisher": {
"@type": "Organization",
"name": "China Highlights",
"logo": {
"@type": "ImageObject",
"url": "https://data.asiahighlights.com/pic/logo-ah.png"
}
}
}
</script>

@ -0,0 +1,28 @@
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://www.chinahighlights.com/"
}
<?php foreach ($breadcrumb_data as $index => $item) {?>
,{
"@type": "ListItem",
"position": <?php echo ($index + 2) ?>,
"name": "<?php echo $item['ic_url_title'] ?>",
"item": "https://www.chinahighlights.com<?php echo $item['ic_url'] ?>"
}
<?php }?>
<?php if ($information->ic_url != '/') {?>
,{
"@type": "ListItem",
"position": <?php echo (count($breadcrumb_data) + 2) ?>,
"name": "<?php echo $information->ic_title ?>"
}
<?php }?>
]
}
</script>

@ -371,5 +371,7 @@
}
}
</script>
<!--@STRUCTURED-DATA-BREADCRUMB-BLOCK@-->
<!--@STRUCTURED-DATA-ARTICLE-BLOCK@-->
</body>
</html>
Loading…
Cancel
Save