三月 20
因为前两天更改了一下本杂货铺子的Permalinks,虽然使用了Permalinks Migration Plugin用来防止通过搜索引擎的找到这的朋友碰到那个恶心的404页面,不过感觉还是不大踏实,忽然想起很久以前好像看到过有个插件可以让通过搜索引擎找过的朋友看到站点上跟搜索关键词的相关内容。想了想,还是把它装起来吧。
找了下,这东西叫做landing-sites,装起来倒是不费劲。不过plugin这个东西,不是自己写的,难免有些细节的地方不是很满意,于是又花了点时间修改了这个东西,然后再微调了下目前所用的K2主题。以下就是整个过程的纪录:
- 下载landing-sites
- 修改一下landing-sites的原始文件,使之支持百度、live等搜索引擎,同时让landing-sites可以输出正确编码的百度搜索关键词。所作的修改如下:
- diff -Nur old/landingsites13.php new/landingsites13.php
- --- old/landingsites13.php 2006-06-06 18:22:24.000000000 +0800
- +++ new/landingsites13.php 2007-03-20 19:40:49.000000000 +0800
- @@ -14,10 +14,16 @@
- $search_engines = array('google.com' => 'q',
- 'go.google.com' => 'q',
- +/* add by coolzsb,to add google.cn & baidu.com search result */
- + 'google.cn' => 'q',
- + 'go.google.cn' => 'q',
- + 'baidu.com' => 'wd',
- 'maps.google.com' => 'q',
- 'local.google.com' => 'q',
- 'search.yahoo.com' => 'p',
- 'search.msn.com' => 'q',
- +/* add by coolzsb,to add live.com search result */
- + 'search.live.com' => 'q',
- 'msxml.excite.com' => 'qkw',
- 'search.lycos.com' => 'query',
- 'alltheweb.com' => 'q',
- @@ -79,7 +85,11 @@
- $query_array = preg_split('/[\s,\+\.]+/',$query);
- $query_terms = implode(' ', $query_array);
- $terms = htmlspecialchars(urldecode($query_terms));
- -
- +/* add by coolzsb, to convert the key word of baidu.com from gbk to utf-8 */
- + if (ls_get_refer() == 'baidu.com') {
- + $terms = mb_convert_encoding($terms,"utf-8","gb2312");
- + }
- +/* add by coolzsb, to convert the key word of baidu.com from gbk to utf-8 */
- return $terms;
- }
- @@ -170,7 +180,7 @@
- }
- }
- -/*
- +
- function ls_install() {
- global $wpdb;
- global $table_prefix;
- @@ -184,11 +194,11 @@
- }
- register_activation_hook(__FILE__, 'ls_install');
- -*/
- +
- function ls_set_header() {
- if (ls_getinfo('isref')) header('Vary: Referer', FALSE);
- }
- add_action('init', 'ls_set_header');
- -?>
- \ No newline at end of file
- +?>
- 像正常安装wordpress的plugin一样在管理后台增加landing-sites插件。
- 修改K2主题,使之的侧边栏和404页面支持此项功能,我对K2所作的修改如下:
- diff -Nur old/404.php new/404.php
- --- old/404.php 2007-03-20 19:35:21.000000000 +0800
- +++ new/404.php 2007-03-20 19:38:39.000000000 +0800
- @@ -13,7 +13,19 @@
- </div>
- <div>
- - <p><?php _e('Oh no! You\'re looking for something which just isn\'t here! Fear not however, errors are to be expected, and luckily there are tools on the sidebar for you to use in your search for what you need.','k2_domain'); ?></p>
- +<p>
- +<?php if (ls_getinfo('isref')) { ?>
- +<div>
- +<h2><?php ls_getinfo('terms'); ?></h2>
- +<p>鍏勫紵,浣犳槸鍦?<?php ls_getinfo('referrer'); ?> 鎼滅储 "<i><?php ls_getinfo('terms'); ?></i>" 鎵惧埌杩欎釜鏉傝揣閾虹殑鍚э紵鍜辩殑閾哄瓙閲岄潰杩樻湁浜涚浉鍏崇殑绉佹埧鍜氬挌锛屼綘鐪嬬湅鏄笉鏄篃浼氭湁鐐瑰叴瓒?</p>
- +<?php if (!(is_single())) { ?>
- +<ul>
- +<?php UTW_ShowRelatedPostsForCurrentPost("posthtmllist",'','10'); ?>
- +</ul>
- +<?php } ?>
- +</div>
- +<?php } ?> </p>
- +<p><?php _e('Oh no! You\'re looking for something which just isn\'t here! Fear not however, errors are to be expected, and luckily there are tools on the sidebar for you to use in your search for what you need.','k2_domain'); ?></p>
- </div>
- </div> <!-- .hentry .four04 -->
- @@ -31,4 +43,4 @@
- <?php get_footer(); ?>
- -<!-- jegelskerRikke -->
- \ No newline at end of file
- +<!-- jegelskerRikke -->
- diff -Nur old/sidebar.php new/sidebar.php
- --- old/sidebar.php 2007-03-20 19:39:25.000000000 +0800
- +++ new/sidebar.php 2007-03-20 19:39:37.000000000 +0800
- @@ -93,6 +93,7 @@
- <?php } ?>
- +
- <?php /* Brian's Latest Comments */ if ((function_exists('blc_latest_comments')) and is_home()) { ?>
- <div>
- <h2><?php _e('Comments','k2_domain'); ?></h2>
- @@ -124,8 +125,17 @@
- </div>
- <?php } ?>
- -
- -
- +<?php if (ls_getinfo('isref')) { ?>
- +<div>
- +<h2><?php ls_getinfo('terms'); ?></h2>
- +<p>鍏勫紵,浣犳槸鍦?<?php ls_getinfo('referrer'); ?> 鎼滅储 "<i><?php ls_getinfo('terms'); ?></i>" 鎵惧埌杩欎釜鏉傝揣閾虹殑鍚э紵鍜辩殑閾哄瓙閲岄潰杩樻湁浜涚浉鍏崇殑绉佹埧鍜氬挌锛屼綘鐪嬬湅鏄笉鏄篃浼氭湁鐐瑰叴瓒?</p>
- +<?php if (!(is_single())) { ?>
- +<ul>
- +<?php UTW_ShowRelatedPostsForCurrentPost("posthtmllist",'','10'); ?>
- +</ul>
- +<?php } ?>
- +</div>
- +<?php } ?>
- <?php /* Latest Entries */ if ( (is_home()) or (is_search() or (is_404()) or ($notfound == '1')) or (function_exists('is_tag') and is_tag()) or ( (is_archive()) and (!is_author()) ) ) { ?>
- <div>
- @@ -209,7 +219,6 @@
- <ul>
- <?php UTW_ShowRelatedPostsForCurrentPost("posthtmllist",'','10'); ?>
- -
- </ul>
- </div>
- <?php } ?>
附录:
- landing-sites的官方网站上的安装文档里面有个符号错误,会导致根据该说明修改的主题出错,其实也就是把php的变量引用符的半角单引号变成了全角单引号,结果就导致了大部分不是那么细心的人跟着文档走的时候发现:根据官方文档根本就没法使用landing-sites-----包括我在内-_-!
- landing-sites是提供了读取相关文章的函数,不过,我个人还是比较喜欢用UTW的UTW_ShowRelatedPostsForCurrentPost函数(根据tag来判断相关文章),所以到最后的修改就是上头的样子了。
- 没有什么再好附录了。
三月 30th, 2007 at 1:49 pm
Permalinks Migration Plugin这个插件好像还是需要服务器支持mod_rewrite功能,郁闷死了,用windows做wordpress服务器就是烦!
另外Coolzsb大哥,关注你的blog很久了,不知道能不能交换下链接,你的我已经添加了
我的blog名称: Puppy blog
blog地址: http://puppyguy.org
三月 30th, 2007 at 5:51 pm
首先,Permalinks Migration Plugin是不需要mod_rewrite支持的。
其次,如果你要设置Permalinks的话,windows底下也可以用apache啊;就算你用的是iis,也是有类似的rewrite的iis插件,印象中有个不要钱的版本,是只支持一个iis虚拟目录的。你可以去google去找一下,资料很多的。
2007年三月 30 日 1:49 pm,puppyguy大声嚷嚷道:
嗯,发现你的工作可能和我差不多,杂货铺子链杂货铺子咯
签名
------
物以类聚,人以群分
十一月 2nd, 2007 at 3:49 pm
^-^你那个搜索转了半天转不出结果
十一月 2nd, 2007 at 3:50 pm
下载也下不了嘛……