GH Article 结构化标签

master
LiaoYijun 3 months ago
parent 49334703b6
commit 2c08f9ed84

@ -1893,6 +1893,19 @@ class Information extends CI_Controller {
$meta_product_code = get_meta($information->ic_id, 'meta_product_code'); $meta_product_code = get_meta($information->ic_id, 'meta_product_code');
$ads_by_google = ! empty(get_meta($information->ic_id, 'meta_google_ad_article')); $ads_by_google = ! empty(get_meta($information->ic_id, 'meta_google_ad_article'));
$meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
$meta_addon_picture_mobile = get_meta($information->ic_id, 'meta_addon_picture_mobile');
$article_image_list = [$meta_addon_picture, $meta_addon_picture_mobile];
$article_image_list = array_values(array_filter($article_image_list, function($value) {
return !empty($value);
}));
$article_image_json = json_encode($article_image_list, JSON_UNESCAPED_SLASHES);
$article_published_date = new DateTime($information->is_datetime, new DateTimeZone('UTC'));
$article_modified_date = new DateTime('now', new DateTimeZone('UTC'));
//H1模板替换 //H1模板替换
$data_H1 = []; $data_H1 = [];
$data_H1['infocategory'] = $this->Information_model->get_detail_by_path($information->is_path, 1); //信息所属分类,获取信息顶级节点内容 $data_H1['infocategory'] = $this->Information_model->get_detail_by_path($information->is_path, 1); //信息所属分类,获取信息顶级节点内容
@ -1923,8 +1936,13 @@ class Information extends CI_Controller {
} }
$article_structured_data_content = $this->load->view( $article_structured_data_content = $this->load->view(
'mobile_first/gh-structured-data-article', $template_path . '-structured-data-article', [
['information' => $information, 'author_name' => $data_H1['author'], 'author_url' => $author_url], 'information' => $information,
'article_published_date' => $article_published_date,
'article_modified_date' => $article_modified_date,
'author_name' => $data_H1['author'], 'author_url' => $author_url,
'article_image_urls' => $article_image_json
],
true true
); );
$template = str_replace('<!--@STRUCTURED-DATA-ARTICLE-BLOCK@-->', $article_structured_data_content, $template); $template = str_replace('<!--@STRUCTURED-DATA-ARTICLE-BLOCK@-->', $article_structured_data_content, $template);

@ -7,11 +7,9 @@
"@id": "https://www.globalhighlights.com<?php echo $information->ic_url; ?>" "@id": "https://www.globalhighlights.com<?php echo $information->ic_url; ?>"
}, },
"headline": "<?php echo $information->ic_seo_title; ?>", "headline": "<?php echo $information->ic_seo_title; ?>",
"image": [ "image": <?php echo $article_image_urls; ?>,
"https://images.globalhighlights.com<?php echo $information->ic_photo; ?>" "datePublished": "<?php echo $article_published_date->format('c'); ?>",
], "dateModified": "<?php echo $article_modified_date->format('c'); ?>",
"datePublished": "<?php echo $information->is_datetime; ?>",
"dateModified": "<?php echo date('Y-m-d\TH:i:s'); ?>",
"author": { "author": {
"@type": "Person", "@type": "Person",
"name": "<?php echo $author_name; ?>", "name": "<?php echo $author_name; ?>",

Loading…
Cancel
Save