opencart 添加首页keywords

opencart 添加首页keywords

1. 后台编辑
文件admin/controller/setting/setting.php找到
$this->data[‘entry_meta_description’] = $this->language->get(‘entry_meta_description’);
后面添加
$this->data[‘entry_meta_keywords’] = $this->language->get(‘entry_meta_keywords’);

同一文件查找
if (isset($this->request->post[‘config_meta_description’])) {
$this->data[‘config_meta_description’] = $this->request->post[‘config_meta_description’];
} else {
$this->data[‘config_meta_description’] = $this->config->get(‘config_meta_description’);
}
后面添加
if (isset($this->request->post[‘config_meta_keywords’])) {
$this->data[‘config_meta_keywords’] = $this->request->post[‘config_meta_keywords’];
} else {
$this->data[‘config_meta_keywords’] = $this->config->get(‘config_meta_keywords’);
}

文件admin/language/english/setting/setting.php
查找$_[‘entry_meta_description’] = ‘Meta Tag Description:’;
后面添加$_[‘entry_meta_keywords’] = ‘Meta Tag Keywords:’;
文件admin/view/template/setting/setting.tpl找到
<tr>
<td><?php echo $entry_meta_description; ?></td>
<td><textarea name=”config_meta_description” cols=”40″ rows=”5″><?php echo $config_meta_description; ?></textarea></td>
</tr>
后面添加
<tr>
<td><?php echo $entry_meta_keywords; ?></td>
<td><textarea name=”config_meta_keywords” cols=”40″ rows=”3″><?php echo $config_meta_keywords; ?></textarea></td>
</tr>

2. 前台修改
文件catalog/controller/common/home.php找到
$this->document->setDescription($this->config->get(‘config_meta_description’));
后面添加
$this->document->setKeywords($this->config->get(‘config_meta_keywords’));

文件catalog/view/theme/default/template/common/header.tpl查看有没有
<?php if ($keywords) { ?>
<meta name=”keywords” content=”<?php echo $keywords; ?>” />
<?php } ?>
头部没有这段代码就添加过去

进入后台System->Settings写入keywords关键词信息,没有信息前台不会显示

发表评论

© 2022. powered by PHP 个人小站