更正结构化标签代码错误

master
Layne 1 year ago
parent 23ff03d4e4
commit d711e5e333

@ -1949,12 +1949,15 @@ class Information extends CI_Controller
$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'));
$data['ads_by_google'] = $ads_by_google; $data['ads_by_google'] = $ads_by_google;
$data['author'] = ''; //获取作者信息 $data['author'] = ''; //获取作者信息
$author_type = null;
$author = $this->Operator_model->get_author_nikename($information->ic_author); $author = $this->Operator_model->get_author_nikename($information->ic_author);
if (!empty ($author)) { if (!empty ($author)) {
$author_type = 'operator';
$data['author'] = $author->OPI_FirstName; $data['author'] = $author->OPI_FirstName;
} else { } else {
$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)) {
$author_type = 'info_author';
$data['author'] = $author_web->a_name; $data['author'] = $author_web->a_name;
$author = $author_web; $author = $author_web;
} }
@ -1963,12 +1966,6 @@ class Information extends CI_Controller
$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, 'author_type' => $author_type), array('information' => $information, 'author' => $author, 'author_type' => $author_type),

@ -15,11 +15,13 @@
"author": { "author": {
"@type": "Person", "@type": "Person",
"name": "<?php "name": "<?php
if ($author_type == 'operator') { if ($author_type) {
echo $author->OPI_FirstName; if ($author_type == 'operator') {
} else if ($author_type = 'info_author') { echo $author->OPI_FirstName;
echo $author->a_name; } else if ($author_type = 'info_author') {
} echo $author->a_name;
}
}
?>" ?>"
}, },
"publisher": { "publisher": {

Loading…
Cancel
Save