CH Article Structured Data

master
LiaoYijun 3 months ago
parent 24df9ca4f9
commit 72704e49c5

@ -1186,9 +1186,26 @@ class Information extends CI_Controller {
if (empty($meta_product_code)) { if (empty($meta_product_code)) {
$template = str_replace('?product_code=', '', $template); $template = str_replace('?product_code=', '', $template);
$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'));
$article_structured_data_content = $this->load->view( $article_structured_data_content = $this->load->view(
$template_path . '-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['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.chinahighlights.com<?php echo $information->ic_url; ?>" "@id": "https://www.chinahighlights.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.chinahighlights.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