|
今天在群里,看到大家讨论如何修改oc的首页key word,引起讨论,后来﹏『番茄-处女座』﹏ヾ(843484847) 写了代码,我代转发出来,以供大家参考
打开模板头部文件:catalog\view\theme\模板名\template\common\header.tpl
<?php if ($keywords) { ?> <!--这是原本的代码,判断:当关键=true的时候就执行下面(也就是不等于空的时候)-->
<meta name="keywords" content="<?php echo $keywords; ?>" /> <!--不等于空的时候就 执行这一行-->
<?php }else { ?> <!--我在这里加了一个, 否则(不等于空) 就把 TITLE当作关键字-->
<meta name="keywords" content="<?php echo $title; ?>" /><!-- 把TITLE输出到KEYWORD-->
<?php }?>
还有另外一个版本,我也发下,这个版本(好像是群里的 孤狐尊者 (29294961))
孤狐尊者 (29294961) 14:58:58
编辑文件admin下controller下setting下setting.php文件
查找如下代码
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_keyword'])) {
$this->data['config_meta_keyword'] = $this->request->post['config_meta_keyword'];
} else {
$this->data['config_meta_keyword'] = $this->config->get('config_meta_keyword');
}
孤狐尊者 (29294961) 15:00:33
然后再编辑
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 'Meta Tag Keyword:'; ?></td>
<td><textarea name="config_meta_keyword" cols="40" rows="5"><?php echo $config_meta_keyword; ?></textarea></td>
</tr>
孤狐尊者 (29294961) 15:02:21
然后编辑前台文件
catalog下controller下common下home.php文件
查找代码$this->document->setDescription($this->config->get('config_meta_description'));
在下面添加一行
$this->document->setKeywords($this->config->get('config_meta_keyword'));
/**
* 获取客户端IP
* */
public static function getClientIp()
{
if (getenv ( "HTTP_CLIENT_IP" ) && strcasecmp ( getenv ( "HTTP_CLIENT_IP" ), "unknown" ))
$ip = getenv ( "HTTP_CLIENT_IP" );
else if (getenv ( "HTTP_X_FORWARDED_FOR" ) && strcasecmp ( getenv ( "HTTP_X_FORWARDED_FOR" ), "unknown" ))
$ip = getenv ( "HTTP_X_FORWARDED_FOR" );
else if (getenv ( "REMOTE_ADDR" ) && strcasecmp ( getenv ( "REMOTE_ADDR" ), "unknown" ))
$ip = getenv ( "REMOTE_ADDR" );
else if (isset ( $_SERVER ['REMOTE_ADDR'] ) && $_SERVER ['REMOTE_ADDR'] && strcasecmp ( $_SERVER ['REMOTE_ADDR'], "unknown" ))
$ip = $_SERVER ['REMOTE_ADDR'];
else
$ip = "unknown";
return ($ip);
} |
|