From d711e5e333ade43cd902e42ebd9214d408fca5da Mon Sep 17 00:00:00 2001 From: Layne <2320908474@qq.com> Date: Thu, 21 Mar 2024 10:43:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=AD=A3=E7=BB=93=E6=9E=84=E5=8C=96?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E4=BB=A3=E7=A0=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/information.php | 9 +++------ .../mobile_first/ah-structured-data-article.php | 12 +++++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/application/controllers/information.php b/application/controllers/information.php index 906d597f..b7b7d5f9 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -1949,12 +1949,15 @@ class Information extends CI_Controller $ads_by_google = !empty (get_meta($information->ic_id, 'meta_google_ad_article')); $data['ads_by_google'] = $ads_by_google; $data['author'] = ''; //获取作者信息 + $author_type = null; $author = $this->Operator_model->get_author_nikename($information->ic_author); if (!empty ($author)) { + $author_type = 'operator'; $data['author'] = $author->OPI_FirstName; } else { $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等 if (!empty ($author_web)) { + $author_type = 'info_author'; $data['author'] = $author_web->a_name; $author = $author_web; } @@ -1963,12 +1966,6 @@ class Information extends CI_Controller $template_H1 = $this->load->view($template_path . '-h1', $data, true); $template = str_replace('', $template_H1, $template); // 结构化标签: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( $template_path . '-structured-data-article', array('information' => $information, 'author' => $author, 'author_type' => $author_type), diff --git a/application/views/mobile_first/ah-structured-data-article.php b/application/views/mobile_first/ah-structured-data-article.php index 93d63653..5a46d0ba 100644 --- a/application/views/mobile_first/ah-structured-data-article.php +++ b/application/views/mobile_first/ah-structured-data-article.php @@ -15,11 +15,13 @@ "author": { "@type": "Person", "name": "OPI_FirstName; - } else if ($author_type = 'info_author') { - echo $author->a_name; - } + if ($author_type) { + if ($author_type == 'operator') { + echo $author->OPI_FirstName; + } else if ($author_type = 'info_author') { + echo $author->a_name; + } + } ?>" }, "publisher": {