结构化标签新增在线作者判断

master
Layne 1 year ago
parent 747effe3e3
commit 23ff03d4e4

@ -1956,15 +1956,22 @@ class Information extends CI_Controller
$author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等 $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等
if (!empty ($author_web)) { if (!empty ($author_web)) {
$data['author'] = $author_web->a_name; $data['author'] = $author_web->a_name;
$author = $author_web;
} }
} }
$data['breadcrumb_data'] = $breadcrumb_data; $data['breadcrumb_data'] = $breadcrumb_data;
$template_H1 = $this->load->view($template_path . '-h1', $data, true); $template_H1 = $this->load->view($template_path . '-h1', $data, true);
$template = str_replace('<!--@HEAD_1@-->', $template_H1, $template); $template = str_replace('<!--@HEAD_1@-->', $template_H1, $template);
// 结构化标签Article // 结构化标签Article
$author_type = null;
if (!empty($author)) {
$author_type = 'operator';
} else if (!empty($author_web)) {
$author_type = 'info_author';
}
$article_structured_data_content = $this->load->view( $article_structured_data_content = $this->load->view(
$template_path . '-structured-data-article', $template_path . '-structured-data-article',
array('information' => $information, 'author' => $author), array('information' => $information, 'author' => $author, 'author_type' => $author_type),
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);

@ -14,7 +14,13 @@
"dateModified": "<?php echo date('Y-m-d\TH:i:s'); ?>", "dateModified": "<?php echo date('Y-m-d\TH:i:s'); ?>",
"author": { "author": {
"@type": "Person", "@type": "Person",
"name": "<?php echo $author->OPI_FirstName; ?>" "name": "<?php
if ($author_type == 'operator') {
echo $author->OPI_FirstName;
} else if ($author_type = 'info_author') {
echo $author->a_name;
}
?>"
}, },
"publisher": { "publisher": {
"@type": "Organization", "@type": "Organization",

Loading…
Cancel
Save