wordpree评论链接重定向方法已有很多人分享,但是对于typecho我却找不到类似这样的详细修改方法,typecho官方文档不完整,而我又是php菜鸟,所以折腾了好久才修改好。通过这次折腾让我更是怀念wordpress了。
打开var/Widget/Abstract/Comments.php文件,寻找
if ($this->url && $autoLink) {
echo '<a href="' , $this->url , '"' , ($noFollow ? ' rel="external nofollow"' : NULL) , '>' , $this->author , '</a>';
} else {
echo $this->author;
}修改为:
if ($this->url && $autoLink) {
if(strpos($this->url, $this->options->siteUrl)!==false) {
echo '<a href="', $this->url, '">', $this->author, '</a>';
} else {
echo '<a href="', $this->options->siteUrl, 'go.html?url=', urlencode($this->url), '"', ' rel="nofollow"', '>', $this->author, '</a>';
}
} else {
echo $this->author;
}跳转页采用的是html静态页+javescript方式跳转,你也可以改用php方式,我的跳转go.html代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>羊窝网中转页</title>
<style type="text/css">
#show{width:500px;margin:100px auto 0;font-size:18px;color:blue;}
#show span{color:red;font-weight:blod;}
</style>
</head>
<body>
<div id="show"></div>
<script type="text/javascript">
<!--
function getUrl(){
var theUrl=location.href.split('?url=');
if(theUrl.length==1)
return 'http://www.yangwo.net';
return decodeURIComponent(theUrl[1]);
}
var showme=document.getElementById('show');
showme.innerHTML='正在为你跳转到:<span>'+getUrl()+'</span>';
location=getUrl();
//-->
</script>
</body>
</html>
评论 (0)