feat: 增加作者头像、领域

master
LiaoYijun 9 months ago
parent c405f359c9
commit 76d17dd763

@ -2695,17 +2695,21 @@ class Information extends CI_Controller
$ads_by_google = !empty(get_meta($information->ic_id, 'meta_google_ad_article'));
$data['meta_news_createdate'] = $this->get_publish_date_in_6_month($information);
$data['ads_by_google'] = $ads_by_google;
$data['author'] = ''; //获取作者信息
$data['author_name'] = ''; //获取作者信息
$author = $this->Operator_model->get_author_nikename($information->ic_author);
$author_url = '';
$author_info = $this->get_author_info('japanhighlights.com', $author->OPI_Code);
$data['author_info'] = $author_info;
if (!empty($author)) {
$data['author'] = $author->OPI_FirstName;
$data['author_name'] = $author->OPI_FirstName;
$data['OPI_Code'] = $author->OPI_Code;
$author_url = $this->get_author_url('www.japanhighlights.com', $author->OPI_Code);
} else {
$author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等
if (!empty($author_web)) {
$data['author'] = $author_web->a_name;
$data['author_name'] = $author_web->a_name;
}
}
$data['breadcrumb_data'] = $breadcrumb_data;
@ -2714,7 +2718,7 @@ class Information extends CI_Controller
// 结构化标签Article
$article_structured_data_content = $this->load->view(
$template_path . '-structured-data-article',
array('information' => $information, 'author_name' => $data['author'], 'author_url' => $author_url),
array('information' => $information, 'author_name' => $data['author_name'], 'author_url' => $author_url),
true
);
$template = str_replace('<!--@STRUCTURED-DATA-ARTICLE-BLOCK@-->', $article_structured_data_content, $template);
@ -6143,7 +6147,7 @@ class Information extends CI_Controller
return true;
}
public function get_author_url($domain_name, $OPI_Code)
public function get_author_url($domain_name, $OPI_Code)
{
$OPI_CodeUrls = [
'zzy' => 'https://' . $domain_name .'/aboutus/team/ruru-zhou',
@ -6189,4 +6193,84 @@ class Information extends CI_Controller
return '';
}
}
// 获取作者信息,包括头像、领域、主页
private function get_author_info($domain_name, $OPI_Code)
{
// 定义URL模板
$baseUrl = 'https://www.' . $domain_name . '/aboutus/team/';
$urlSuffix = ($domain_name == 'chinahighlights.com') ? '.htm' : '';
// 共享的URL结构
$OPI_CodeUrls = [
'zzy' => $baseUrl . 'ruru-zhou' . $urlSuffix,
'HWT' => $baseUrl . 'mike-he' . $urlSuffix,
'CA' => $baseUrl . 'carol-wang' . $urlSuffix,
'SI' => $baseUrl . 'simon-huang' . $urlSuffix,
'TJQ' => $baseUrl . 'cindy-tang' . $urlSuffix,
'CLA' => $baseUrl . 'claire-wang' . $urlSuffix,
'Albee' => $baseUrl . 'albee-ning' . $urlSuffix,
'KM' => $baseUrl . 'kimi-huang' . $urlSuffix,
'RY' => $baseUrl . 'rita-yu' . $urlSuffix,
'QMY' => $baseUrl . 'chris-quan' . $urlSuffix,
'CY' => $baseUrl . 'cynthia-li' . $urlSuffix,
'Vicky' => $baseUrl . 'vicky-leng' . $urlSuffix,
'LXW' => $baseUrl . 'carper-li' . $urlSuffix,
];
// 共享的头像和专长映射
$expertiseMap = [
'zzy' => [
'expertise' => 'Japan Content Expert',
'avatar' => 'https://images.'. $domain_name . '/allpicture/2024/03/bc1583b921a24cc3be739e57d290f582_cut_300x300_608.JPG'
],
'HWT' => [
'expertise' => 'Thailand Content Expert',
'avatar' => 'https://images.'. $domain_name . '/allpicture/2024/03/5dc9f81961c24725895205d65123b8e7_cut_300x300_608.JPG'
],
'TJQ' => [
'expertise' => 'Thailand Content Expert',
'avatar' => 'https://images.'. $domain_name . '/allpicture/2024/03/513a1f2af9e54157932fbe157a8862d3_cut_300x300_608.JPG'
],
'RY' => [
'expertise' => 'Vietnam Content Expert',
'avatar' => 'https://images.'. $domain_name . '/allpicture/2024/03/8895dc76301e47a094c0c86048a2c39a_cut_300x300_608.JPG'
],
'QMY' => [
'expertise' => 'China Content Expert',
'avatar' => 'https://images.'. $domain_name . '/allpicture/2024/03/8097b02a5f2c4486824ffecc045a4125_cut_300x300_608.JPG'
],
'CY' => [
'expertise' => 'Japan Content Expert',
'avatar' => 'https://images.'. $domain_name . '/allpicture/2024/03/65499011c0714e0aa1271bc300d9399d_cut_300x300_608.JPG'
],
'Vicky' => [
'expertise' => 'Japan Content Expert',
'avatar' => 'https://images.'. $domain_name . '/allpicture/2024/03/a2d6ac5a7ccb4c06a3d8f1bbf939bdf5_cut_300x300_608.JPG'
],
'LXW' => [
'expertise' => 'Japan Content Expert',
'avatar' => 'https://images.'. $domain_name . '/allpicture/2024/03/b002b9e61b464e24956fea8f17e2ef37_cut_300x300_608.JPG',
],
];
// 构建作者数据
$authorData = [];
foreach ($OPI_CodeUrls as $key => $url) {
if (isset($expertiseMap[$key])) {
$authorData[$key] = [
'url' => $url,
'avatar' => $expertiseMap[$key]['avatar'],
'expertise' => $expertiseMap[$key]['expertise'],
'name' => $expertiseMap[$key]['name']
];
}
}
// 合并重复项
$authorData['2'] = $authorData['zzy'];
$authorData['zzyGH'] = $authorData['zzy'];
return isset($authorData[$OPI_Code]) ? $authorData[$OPI_Code] : ['url' => '', 'avatar' => '', 'expertise' => '', 'name' => ''];
}
}

@ -6,7 +6,7 @@
<img src="<?php echo $meta_addon_picture; ?>"
alt="<?php echo !empty($information->ic_title)?$information->ic_title:'H1 title japanhighlights mobile first template'; ?>" class="img-responsive" fetchpriority="high">
<?php } ?>
</div>
</div>
<div class="infocategory">
@ -20,32 +20,12 @@
<h1 class="whitefont"><?php echo !empty($information->ic_title)?$information->ic_title:'H1 title japanhighlights mobile first template'; ?></h1>
</div>
<?php
$OPI_CodeUrls = [
'zzy' => 'https://www.japanhighlights.com/about-us/meet-our-team/ruru-zhou',
'2' => 'https://www.japanhighlights.com/about-us/meet-our-team/ruru-zhou',
'HWT' => 'https://www.japanhighlights.com/about-us/meet-our-team/mike-he',
'CA' => 'https://www.japanhighlights.com/about-us/meet-our-team/carol-wang',
'SI' => 'https://www.japanhighlights.com/about-us/meet-our-team/simon-huang',
'TJQ' => 'https://www.japanhighlights.com/about-us/meet-our-team/cindy-tang',
'CLA' => 'https://www.japanhighlights.com/about-us/meet-our-team/claire-wang',
'Albee' => 'https://www.japanhighlights.com/about-us/meet-our-team/albee-ning',
'KM' => 'https://www.japanhighlights.com/about-us/meet-our-team/kimi-huang',
'RY' => 'https://www.japanhighlights.com/about-us/meet-our-team/rita-yu',
'QMY' => 'https://www.japanhighlights.com/about-us/meet-our-team/chris-quan',
'CY' => 'https://www.japanhighlights.com/about-us/meet-our-team/cynthia-li',
'Vicky' => 'https://www.japanhighlights.com/about-us/meet-our-team/vicky-leng',
'LXW' => 'https://www.japanhighlights.com/about-us/meet-our-team/carper-li',
'zzyGH' => 'https://www.japanhighlights.com/about-us/meet-our-team/ruru-zhou',
];
$OPI_Code = empty($OPI_Code) ? '' : $OPI_Code;
if (!empty($meta_news_createdate)) {?>
<div class="authorupdate list_content">
Written by
<?php if (array_key_exists($OPI_Code, $OPI_CodeUrls)) {?>
<strong><a href="<?php echo $OPI_CodeUrls[$OPI_Code]; ?>" target="_blank"><?php echo $author; ?></a></strong>
<?php } else { ?>
<strong><?php echo $author; ?></strong>
<?php }?>
Updated <?php echo date("M. j, Y", strtotime($meta_news_createdate)); ?>
</div>
<div class="authorupdate list_content" style="line-height: 1.3rem; font-size: 15px;">
<a href="<?php echo $author['info->url']; ?>" target="_blank">
<img src="<?php echo $author_info['avatar']; ?>" alt="<?php echo $author_info['expertise']; ?>" style="width: 40px; border-radius: 50%; margin-right: 10px; float: left;">
</a>
Written by <strong><a href="<?php echo $author_info['url']; ?>" target="_blank"><?php echo $author_name; ?></a></strong> <?php echo $author_info['expertise']; ?><br>
Updated <?php echo date("M. j, Y", strtotime($meta_news_createdate)); ?>
</div>
<?php } ?>
Loading…
Cancel
Save