<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>DB2</title>
<link>http://www.aiview.com/</link>
<description>Alex&apos;s Public Information Portal.</description>
<copyright>Copyright 2008</copyright>
<lastBuildDate>Mon, 14 May 2007 13:11:33 +0700</lastBuildDate>
<generator>http://www.movabletype.org/?v=3.34</generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs> 

<item>
<title>让你的Blogroll 看起来更生动</title>
<description><![CDATA[<p>
<a href="http://plugins.movalog.com/mt-blogroll/">Blogroll</a>  是<a href="http://www.movabletype.com/">MT</a>  的一个非常强大的插件，它的众多功能是围绕着<a href="http://www.aiview.com/2006/12/refine_and_add_new_features_to_my_web_site.html#12">链接管理</a> 展开的，使用它，我可以很方便的在侧边栏添加一个新的外部或者内部链接，而无需去直接修改模板。
</p>
<p>
现今，相当一部分bloger 都为自己的blog 设计有icon，一般在站点根目录下，命名为favicon.ico。我们可以在他们的链接前自动加上他们自己的icon，这样可以使链接看起来更生动，让那些对其有印象的访问者可以迅速识别出来。
</p>
<h4>Favicon&nbsp;</h4>
<p>
Blogroll 不支持这个功能，我找到了另外一个插件<a href="http://gemal.dk/mt/favicon.html">Favicon 1.4</a> ，但它仅仅在comments 与 trackback 的上下文中有效，并不支持Blogroll，我对其进行了小的改动，增加了一小段代码（加重部分），使其支持Blogroll。 
</p>
<p>
plugin/Favicon/favicon.pl
</p>
<pre class="code">
sub favicon {
        my($ctx, $args) = @_;
        my $c;
        my $u;
        if ($c = $ctx->stash("ping")) {
                favicon_debug("Trackback in MTFavicon");
                $u = $c->source_url;
        } elsif ($c = $ctx->stash("comment")) {
                favicon_debug("Comment in MTFavicon");
                $u = $c->url;
                favicon_debug("URL for comment ID <" . $c->id . "> is <$u>");
<span class="emphasis">        } elsif ($c = $ctx->stash("br_entry")) {
                favicon_debug("Blogroll in MTFavicon");
                $u = $c->uri;</span>
        } else {
                favicon_debug("Error: MTFavicon called without a comment or trackback in context");
                return $ctx->error("Error: MTFavicon called without a comment or trackback in context");
        }
        return favicon_return($u, $ctx, $args);
}
</pre>
<p>
我使用MT 3.34 与Blogroll 2.51，如果您认为合适，可以直接下载修改过的<a href="../../ref/2007/05/favicon.tar.gz">favicon.pl</a> 。
</p>
<p>
进行以上修改，需要参考以下两个文件：
</p>
<pre>
plugin/Blogroll/Blogroll.pl
plugin/Blogroll/lib/Blogroll/Template/ContextHandlers.pm 
</pre>
<h4>Blogroll</h4>
<p>
为了显示icon，接下来需要修改Blogroll 部分的模板，添加一部分代码（加重的部分），以下是一个的例子：
</p>
<pre class="code">
&lt;ul&gt;
&lt;MTBlogrollLinks&gt;
&lt;li&gt;
<span class="emphasis">    &lt;MTFaviconIfAvailable&gt;
&lt;img src=&quot;&lt;$MTFavicon$&gt;&quot; alt=&quot;Siteicon&quot; title=&quot;Siteicon&quot; height=&quot;16&quot; width=&quot;16&quot; /&gt;
&lt;/MTFaviconIfAvailable&gt;</span>
&lt;a href=&quot;&lt;$MTBlogrollLinkURI$&gt;&quot;&gt;&lt;$MTBlogrollLinkName$&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/MTBlogrollLinks&gt;
&lt;ul&gt;
</pre>
<p>
如果你还没有自己的favicon.ico，可以在这里，<a href="http://www.chami.com/html-kit/services/favicon/">使用自己的图片免费生成一个</a> 。&nbsp;
</p>
<h4>延展阅读</h4>
<ul>
	<li><a href="http://www.sixapart.com/movabletype/docs/plugin-tut">How to Write a Plugin</a></li>
	<li><a href="http://www.sixapart.com/movabletype/docs/mtapi_index">mtapi_index - Index of MT API documentation</a> </li>
</ul>
<p>
&nbsp;
</p>
]]></description>
<link>http://www.aiview.com/2007/05/make_your_blogroll_more_vivid.html</link>
<guid>http://www.aiview.com/2007/05/make_your_blogroll_more_vivid.html</guid>
<category>MT</category>
<pubDate>Mon, 14 May 2007 13:11:33 +0700</pubDate>
</item>
<item>
<title>恢复MT 控制台密码</title>
<description><![CDATA[<p>
<a href="http://blog.thought-mesh.net/solidwallofcode/movable_type/resetting_a_mov.php/ping">这篇文章</a> 描述了从DB 恢复MT 控制台密码的方法。
</p>
<p>
$ perl -e &quot;print crypt(&#39;password&#39;, &#39;ac&#39;);&quot;
</p>
<p>
mysql&gt; update mt_author set author_password = &#39;???&#39; where author_name = &#39;XXX&#39;;
</p>
<p>
使用print 出来的字符串替换&quot;???&quot;，&quot;XXX&quot; 是登录用户名。然后使用&quot;password&quot; 作为密码即可登录。
</p>
<p>
&quot;password&quot;&nbsp; 与 &quot;ac&quot;&nbsp; 可随意更改。 
</p>
]]></description>
<link>http://www.aiview.com/2007/04/recovery_mt_password_from_db.html</link>
<guid>http://www.aiview.com/2007/04/recovery_mt_password_from_db.html</guid>
<category>MT</category>
<pubDate>Thu, 19 Apr 2007 12:53:29 +0700</pubDate>
</item>
<item>
<title>MT 3.33 至MT3.34</title>
<description><![CDATA[<p>
<a href="http://www.anysql.net/weblog/mt_334_fastcgi.html">升级的好处</a> 我就不多说了，这里介绍一点升级过程中的tips。
</p>
<h4>比较文件</h4>
<p>
将程序解压、解包之后放入与上一版本同级的目录，取名mt3.34
</p>
<p>
./mt<br />
./mt3.34 
</p>
<p>
上一版本因为额外安装有插件以及个别hack文件，不能完整替换，先比较两个目录，使用-q 参数忽略具体文件差异，-r 递归子目录。
</p>
<pre class="cmd">
$ diff -qyr mt3.34 mt |grep Only&nbsp;
</pre>
<p>
Only in mt: mt-config.cgi<br />
Only in mt3.34: mt-config.cgi-original<br />
Only in mt/php/extlib/smarty: .cvsignore<br />
Only in mt/php/plugins: block.MTBlogrollCategories.php<br />
Only in mt/php/plugins: block.MTBlogrollLinkCategories.php<br />
Only in mt/php/plugins: block.MTBlogrollLinkIfTagged.php<br />
Only in mt/php/plugins: block.MTBlogrollLinkIfUpdated.php<br />
Only in mt/php/plugins: block.MTBlogrollLinkTags.php<br />
Only in mt/php/plugins: block.MTBlogrollLinks.php<br />
Only in mt/php/plugins: block.MTBlogrollTags.php<br />
Only in mt/php/plugins: function.MTBlogrollCategoryCount.php<br />
Only in mt/php/plugins: function.MTBlogrollCategoryDesc.php<br />
Only in mt/php/plugins: function.MTBlogrollCategoryDescription.php<br />
Only in mt/php/plugins: function.MTBlogrollCategoryID.php<br />
Only in mt/php/plugins: function.MTBlogrollCategoryLabel.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkBlogAuthor.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkCategory.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkDate.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkDesc.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkDescription.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkID.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkModifiedDate.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkName.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkPriority.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkRel.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkTarget.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkURI.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkURL.php<br />
Only in mt/php/plugins: function.MTBlogrollLinkUpdated.php<br />
Only in mt/php/plugins: function.MTBlogrollTagCount.php<br />
Only in mt/php/plugins: function.MTBlogrollTagID.php<br />
Only in mt/php/plugins: function.MTBlogrollTagName.php<br />
Only in mt/php/plugins: function.MTBlogrollTagRank.php<br />
Only in mt/php/plugins: plugins<br />
Only in mt/plugins: Ajaxify<br />
Only in mt/plugins: Blogroll<br />
Only in mt/plugins: CheckLinks<br />
Only in mt/plugins: Collect<br />
Only in mt/plugins: FlickrPhotos<br />
Only in mt/plugins: TagSupplementals.pl<br />
Only in mt/plugins: mt-archive-dateheader.pl<br />
Only in mt/plugins: mt-varz.pl
</p>
<h4>合并文件&nbsp;</h4>
<p>
然后将上一版本多出或者更新日期更新的文件copy 到新版本，为了保险起见，使用-i 参数确认任何文件覆盖。 
</p>
<pre class="cmd">
$ cp -iur&nbsp; mt/plugins/* mt3.34/plugins&nbsp;
</pre>
<p>
&nbsp;然后手动编辑合并曾经hack 过的文件，在这里我曾经修改了<a href="http://www.kingda.org/archives/kingda/2006/04/mt32_1.html">mysql.pm</a> 以及<a href="http://www.aiview.com/2006/11/power_editing_basename.html">批量编辑basename</a> 所需的相关文件。 
</p>
<pre class="cmd">
$ diff&nbsp; mt3.34/lib/MT/ObjectDriver/DBI/mysql.pm mt/lib/MT/ObjectDriver/DBI/mysql.pm
</pre>
<p>
1c1<br />
&lt; # Copyright 2001-2007 Six Apart. This code cannot be redistributed without<br />
---<br />
&gt; # Copyright 2001-2006 Six Apart. This code cannot be redistributed without<br />
5c5<br />
&lt; # $Id: mysql.pm 1003 2007-01-05 23:46:47Z gboggs $<br />
---<br />
&gt; # $Id: mysql.pm 653 2006-08-04 19:33:48Z bchoate $<br />
63c63<br />
&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $driver-&gt;{dbh}-&gt;do(&quot;SET NAMES &quot; . $c) or<br />
---<br />
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $driver-&gt;{dbh}-&gt;do(&quot;SET NAMES &quot; . $c) or<br />
<span class="hilite">99a100<br />
&gt;&nbsp;&nbsp;&nbsp;&nbsp; $driver-&gt;{dbh}-&gt;do(&quot;SET NAMES &#39;utf8&#39;&quot;);</span><br />
&nbsp;
</p>
<p>
可以使用vi 同时编辑多个文件，使用:n 与:N 命令进行切换，剪贴板缓冲区是共享的，方便copy 代码行。
</p>
<pre class="cmd">
$ vi   mt3.34/lib/MT/ObjectDriver/DBI/mysql.pm   mt/lib/MT/ObjectDriver/DBI/mysql.pm
</pre>
<p>
批量编辑basename 一般在大规模迁移时才会用到，这次就不修改了。
</p>
<p>
cgi-bin 目录的所有升级就完成了，把mt-statics copy 到相应目录，重复以上步骤。
</p>
<h4>版本切换&nbsp;</h4>
<p>
全部完成后，把两组新旧目录名称迅速交换，再打开MT控制台，发现升级已经生效，没遇到任何错误，算是无缝切换。&nbsp;
</p>
]]></description>
<link>http://www.aiview.com/2007/04/tips_for_upgrade_mt_333_to_mt334.html</link>
<guid>http://www.aiview.com/2007/04/tips_for_upgrade_mt_333_to_mt334.html</guid>
<category>MT</category>
<pubDate>Wed, 11 Apr 2007 19:55:36 +0700</pubDate>
</item>
<item>
<title>一直无法接收Trackback</title>
<description><![CDATA[<p>
今天查看网站日志，发现有trackback 进来，但都是403错误，使用自己的msn space进行测试，结果相同。车东给了解决方法：<a href="http://www.chedong.com/blog/archives/001235.html">MT HTTP error: 403 Throttled的原因和解决</a>，统计一下log中的trackback数量，一天有1000多条trackback，而且几乎全部是spam，
</p>
<pre class="cmd">
[hostname]$ grep mt-tb.cgi ./access.log.2007-03-18 |wc -l
</pre>
<pre>
1301
</pre>
<p>
在我的mt-config.cgi加入如下2行
</p>
<pre class="code">
OneHourMaxPings 5000
OneDayMaxPings 20000
</pre>
<p>
再次测试，日志中显示正常code 200，但页面并没有生成trackback 的引用。在Yee <a href="http://iyee.cn/post/wordpress-trackback-problem-in-dreamhost.html">这里</a> ，又找到了部分Dreamhost 主机不支持国内trackback过来的说法，于是，在此blog内部进行了trackback 测试，结果一切正常，证实了Yee 的说法。&nbsp;
</p>
<p>
有趣的是，又有新的发现，在Junk TrackBacks 里面发现了几千个trackback，也包扩我在msn space 后来做的测试。虽然这不能说明Yee 的说法是错误的，但至少可以证明我不在那部分Dreamhost 主机当中。 
</p>
<p>
&nbsp;
</p>
]]></description>
<link>http://www.aiview.com/2007/03/trackback_failure_on_dreamhost.html</link>
<guid>http://www.aiview.com/2007/03/trackback_failure_on_dreamhost.html</guid>
<category>MT</category>
<pubDate>Wed, 21 Mar 2007 03:06:47 +0700</pubDate>
</item>
<item>
<title>Get rollable entry list in MT - postroll.js</title>
<description><![CDATA[<p>
Most of blogers have the recent entry list at the sidebar. Sometime it&#39;s difficult to balance spacing and convenience. People may want more entries in the list, but they may also want to see other feature area without rolling scrollbar too much. I wrote a Javascript <a href="/ref/2007/02/postroll.js" title="Download Javascript file, to use Save As">postroll.js</a>  that make the entry list rollable as far as you expect. 
</p>
<p>
How does it work? Download <a href="/ref/2007/02/postroll.js" title="Download Javascript file, to use Save As">postroll.js</a> to your web server path and include it in your web page that you need the feature. Then edit your tempate like below. The template code is a little thick but works. 
</p>
<pre class="code">
&lt;h2&gt;最近更新|Recent Entries&lt;/h2&gt;
&lt;div id=&quot;recententry&quot; class=&quot;module-content&quot;&gt;
&lt;ul id=&quot;<span class="emphasis">recententry1</span>&quot;&gt;
&lt;MTEntries lastn=&quot;5&quot;&gt;
&lt;li&gt;&lt;$MTInclude module=&quot;Entry Link&quot;$&gt;&lt;/li&gt;
&lt;/MTEntries&gt;
&lt;/ul&gt;
&lt;MTEntries offset=&quot;5&quot; lastn=&quot;1&quot;&gt;
&lt;MTIfNonEmpty tag=&quot;EntryTitle&quot;&gt;&lt;$MTSetVar name=&quot;recententry2&quot; value=&quot;1&quot;$&gt;&lt;/MTIfNonEmpty&gt;
&lt;/MTEntries&gt;
&lt;MTIf name=&quot;recententry2&quot;&gt;
&lt;ul id=&quot;<span class="emphasis">recententry2</span>&quot;&gt;
&lt;MTEntries offset=&quot;5&quot; lastn=&quot;5&quot;&gt;
&lt;li&gt;&lt;$MTInclude module=&quot;Entry Link&quot;$&gt;&lt;/li&gt;
&lt;/MTEntries&gt;
&lt;/ul&gt;
&lt;/MTIf&gt;
&lt;MTEntries offset=&quot;10&quot; lastn=&quot;1&quot;&gt;
&lt;MTIfNonEmpty tag=&quot;EntryTitle&quot;&gt;&lt;$MTSetVar name=&quot;recententry3&quot; value=&quot;1&quot;$&gt;&lt;/MTIfNonEmpty&gt;
&lt;/MTEntries&gt;
&lt;MTIf name=&quot;recententry3&quot;&gt;
&lt;ul id=&quot;<span class="emphasis">recententry3</span>&quot;&gt;
&lt;MTEntries offset=&quot;10&quot; lastn=&quot;5&quot;&gt;
&lt;li&gt;&lt;$MTInclude module=&quot;Entry Link&quot;$&gt;&lt;/li&gt;
&lt;/MTEntries&gt;
&lt;/ul&gt;
&lt;/MTIf&gt;
&lt;MTEntries offset=&quot;15&quot; lastn=&quot;1&quot;&gt;
&lt;MTIfNonEmpty tag=&quot;EntryTitle&quot;&gt;&lt;$MTSetVar name=&quot;recententry4&quot; value=&quot;1&quot;$&gt;&lt;/MTIfNonEmpty&gt;
&lt;/MTEntries&gt;
&lt;MTIf name=&quot;<span class="emphasis">recententry4</span>&quot;&gt;
&lt;ul id=&quot;recententry4&quot;&gt;
&lt;MTEntries offset=&quot;15&quot; lastn=&quot;5&quot;&gt;
&lt;li&gt;&lt;$MTInclude module=&quot;Entry Link&quot;$&gt;&lt;/li&gt;
&lt;/MTEntries&gt;
&lt;/ul&gt;
&lt;/MTIf&gt;
&lt;MTEntries offset=&quot;20&quot; lastn=&quot;1&quot;&gt;
&lt;MTIfNonEmpty tag=&quot;EntryTitle&quot;&gt;&lt;$MTSetVar name=&quot;recententry5&quot; value=&quot;1&quot;$&gt;&lt;/MTIfNonEmpty&gt;
&lt;/MTEntries&gt;
&lt;MTIf name=&quot;<span class="emphasis">recententry5</span>&quot;&gt;
&lt;ul id=&quot;recententry5&quot;&gt;
&lt;MTEntries offset=&quot;20&quot; lastn=&quot;5&quot;&gt;
&lt;li&gt;&lt;$MTInclude module=&quot;Entry Link&quot;$&gt;&lt;/li&gt;
&lt;/MTEntries&gt;
&lt;/ul&gt;
&lt;/MTIf&gt;
&lt;label id=&quot;<span class="emphasis">recententrybar1</span>&quot;&gt;&lt;/label&gt;&lt;label id=&quot;<span class="emphasis">recententrybar2</span>&quot;&gt;&lt;/label&gt;
&lt;!--end #recententry--&gt;
&lt;/div&gt; 
</pre>
&nbsp;The emphasis must be followed in your code, otherwise need to configure yours in postroll.js. <br />
<pre class="code">
// Configuration
Postroll = {
box: [&quot;<span class="emphasis">recententry</span>&quot;],
bar1: [&quot;<span class="emphasis">recententrybar1</span>&quot;],
bar2: [&quot;<span class="emphasis">recententrybar2</span>&quot;],
bar1_txt: &quot;&amp;nbsp;&amp;nbsp;&amp;laquo;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;,
bar2_txt: &quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;raquo;&amp;nbsp;&amp;nbsp;&quot;,
bar1_lnk_title: &quot;Previous 5 entries&quot;,
bar2_lnk_title: &quot;Next 5 entries&quot;
};
</pre>
<p>
Then have this style in the css. I don&#39;t use script to initial the style because this method is quicker for the page first loading. There won&#39;t be a long entry list at a moment then hided by the script. I use script to initial the text link for rolling entries and control the entry roll after all stuffs were loaded. 
</p>
<pre class="code">
#recententry2,
#recententry3,
#recententry4,
#recententry5 {
display: none;
} 
</pre>
<p>
There&#39;s more action you need to take if want it works perfect! Create a file name as ie_onload.js, and have below only line. About <a href="/ie_onlaod.js" title="Download Javascript file, to use Save AS">ie_onload.js</a>  here&#39;s an <a href="http://www.aiview.com/2007/01/windowonload_problem.html">explanation</a>.
</p>
<pre class="code">
&nbsp;try{Postroll.run()}catch(e){} 
</pre>
<p>
This script is able to serve multi-area in one page. That case you should have the configuration like below. It could be 3 groups or more.
</p>
<pre class="code">
&nbsp;// Configuration
Postroll = {
box: [&quot;recententry&quot;, &quot;othertag&quot;],
bar1: [&quot;recententrybar1&quot;, &quot;othertagbar1&quot;],
bar2: [&quot;recententrybar2&quot;, &quot;othertagbar2&quot;]
bar1_txt: &quot;&amp;nbsp;&amp;nbsp;&amp;laquo;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;,
bar2_txt: &quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;raquo;&amp;nbsp;&amp;nbsp;&quot;,
bar1_lnk_title: &quot;Previous 5 entries&quot;,
bar2_lnk_title: &quot;Next 5 entries&quot;
};
</pre>
<h4>Update 2007-02-14&nbsp;</h4>
<p>
I found that there&#39;s one post missed on each 5 posts in the postroll list. The point is that I had&nbsp; wrong <span class="emphasis">offset</span> value in MTEntries tag. I&#39;ve updated the template code above from <span class="emphasis">offset=&quot;6&quot;</span> to <span class="emphasis">offset=&quot;5&quot;</span> and also for the value of 11, 16 and 21. 
</p>
]]></description>
<link>http://www.aiview.com/2007/02/get_rollable_entry_list_in_mt_postrolljs.html</link>
<guid>http://www.aiview.com/2007/02/get_rollable_entry_list_in_mt_postrolljs.html</guid>
<category>MT</category>
<pubDate>Fri, 02 Feb 2007 01:44:46 +0700</pubDate>
</item>
<item>
<title>无法删除MT widget 默认module的问题</title>
<description><![CDATA[升级MT3.3 以后多了不少plugin，其中包括Widgets Manager，Widget 这个词最近在Blog 出现频率很高，也不知道到底是何物，今天google了一下，才知道<a href="http://beta.lib.ntu.edu.tw/?page_id=13">大部分人谈论的Widget</a> 与我要了解的MT Widget 还不是一回事。 这里有篇文章详细介绍：<a href="http://www.yangkang.org/archives/2006/10/movable_typewidgets.html">使用Movable Type的Widgets</a>，我就不废话了。只说一个奇怪的问题，Widget Manager 会在Template 的Module 中生成默认的Widget 可以利用的Module，我已经有了很多类似的Module，于是把已有的Module重命名，在名称前面加上&quot;<span class="emphasis">Widget: </span>&quot;
前缀，这样就可以被Widget Manager 识别，然后将默认的全部删除，但是下一次点击Manage my
Widgets进入后，这些默认的Module
又会自动生成，没有找到解决办法，最后将我自己的Module修改成与默认的具有相同的名字（大小写敏感），才算了事。<br />
]]></description>
<link>http://www.aiview.com/2007/01/mt_widget_module_remove_problem.html</link>
<guid>http://www.aiview.com/2007/01/mt_widget_module_remove_problem.html</guid>
<category>MT</category>
<pubDate>Mon, 29 Jan 2007 19:24:05 +0700</pubDate>
</item>
<item>
<title>重构MT模板结构</title>
<description><![CDATA[<p>
MT默认的模板包含大量的重复或者类似模板代码，当你需要进行一处模板修改时，也许不得不考虑得更多，并在多个模板中同时进行，已达到统一的效果。
模板重构的目的就是尽可能将多个模板之间相同的部分抽象出来，然后在多个模板中进行引用，另外还有趋向于将一组具有相同功能的模板代码放入同一个模板文件
的作用，从而减少模板修改带来的工作量。MT很早就在模板中支持Module，定义好的Module可以通过如下代码进行引用。
</p>
<pre class="emphasis">
&lt;$MTInclude module=&quot;Module Name&quot;$&gt;
</pre>
<p>
我
们需要做的就是把重复的模板代码放在一个个Module中进行定义，然后在模板中去引用他们。经过一定的重构，模板的重用性得到一定的改观，但依然会有一
些冗余的代码，除非MT可以提供一些模板标签，能够让我们判断当前所在的模板而采用不同的Module或者调整细微的模板代码差别。幸运的是，我找到了一
个MT plugin，<a href="http://code.appnel.com/mt-varz">mt-varz</a>  version 0.31。 它提供了更高级的变量支持，支持以下模板标签：
</p>
<p>
&lt;$MTGetVar$&gt;, 
&lt;MTSetVarBlock&gt;, 
&lt;MTIf&gt;, 
&lt;MTUnless&gt;, 
&lt;MTIfOne&gt;, 
&lt;MTUnlessEmpty&gt;, 
&lt;MTUnlessZero&gt;
</p>
<p>
其中部分标签在MT3.3中已经得到支持， mt-varz对其进行了over load，具体细节可以参考此plugin文档(在下载包内)。我们在这里需要用到MT标准标签<span class="emphasis">MTSetVar</span>，以及mt-varz 支持的<span class="emphasis">MTIf</span> 标签。我在每个模板的第一行使用MTSetVar 定义一个变量用于标识当前模板，然后在Module中需要的地方使用MTIf 判断当前模板，并注入相应模板代码。下面是一个例子：
</p>
<p>
Template: Category Archive 
</p>
<pre class="code">
&lt;$MTSetVar name=&quot;Category Archive&quot; value=&quot;1&quot;$&gt; 
...
&lt;$MTInclude module=&quot;Header&quot;$&gt;
...
</pre>
<p>
Template Module: Header  
</p>
<pre class="code">
&lt;head&gt;
<span class="emphasis">&lt;MTIf name=&quot;Category Archive&quot;&gt;</span>
&lt;title&gt;&lt;$MTBlogName encode_html=&quot;1&quot;$&gt;: &lt;$MTArchiveTitle$&gt; Archives&lt;/title&gt;
&lt;/MTIf&gt;
...
&lt;/head&gt; 
</pre>
&lt;$MTSetVar
name=&quot;Category Archive&quot; value=&quot;1&quot;$&gt; 这里value 可以是其它非0值，如果值为1，那么MTIfOne
标签在上面与MTIf 标签的作用相同，加以利用可以进行更精细的控制。除了1以外，目前还不提供对变量值的详细判断。<br />
<p>
经过重构之后，我的Main Index 模板看起来就像这个样子，其它也很类似，模板修改主要在少量的Module中进行。
</p>
<pre class="code">
&lt;$MTSetVar name=&quot;Main Index&quot; value=&quot;1&quot;$&gt;
&lt;$MTInclude module=&quot;Template Header&quot;$&gt; 
&lt;$MTInclude module=&quot;Header&quot;$&gt;  
&lt;MTEntries&gt;
&lt;$MTInclude module=&quot;Entry&quot;$&gt;
&lt;/MTEntries&gt;
&lt;$MTInclude module=&quot;Footer&quot;$&gt;
&lt;$MTInclude module=&quot;Template Footer&quot;$&gt; &nbsp;
</pre>
<p>
更新：经测试，&lt;MTIfOne&gt; 标签不能正确的解析内嵌的&lt;MTElse&gt; 标签，根据不同情况，将在模板rebuild 阶段抛出错误，或者rebuild 通过，但逻辑不符合嵌套关系。下面是一个逻辑错误示例。&lt;MTIf&gt;标签是否存在此问题未作测试。已经report 这个bug 给了<a href="http://code.appnel.com/">Appnel</a>，希望可以解决。 
</p>
<pre class="code">
&lt;MTIfOne name=&quot;Search Result Template&quot;&gt;&lt;MTIfTagSearch&gt;Tag Search&lt;MTElse&gt;None Tag Search&lt;/MTElse&gt;&lt;/MTIfTagSearch&gt;&lt;/MTIfOne&gt;
</pre>
]]></description>
<link>http://www.aiview.com/2007/01/refactoring_mt_template.html</link>
<guid>http://www.aiview.com/2007/01/refactoring_mt_template.html</guid>
<category>MT</category>
<pubDate>Mon, 29 Jan 2007 16:42:37 +0700</pubDate>
</item>
<item>
<title>列出不定期更新的日志</title>
<description><![CDATA[<p>
我有一些这样的日志，需要长期更新，不断追加内容，或者内容经常变化，需要不定期进行更新。它们很容易就被新的日志淹没，从而增加了查找定位的成本。对于这样的日志，我希望可以将它们固定的列在blog边栏，方便随时查看和修改。有两种方法可以方便的实现：
</p>
<ol>
	<li>为这部分日志指定共同的分类（categories）</li>
	<li>为这部分日志指定共同的标签（tags）</li>
</ol>
<p>
指定分类的方法，将会额外增加一个blog分类，可能是不期望的，不过也可能正是使用者所期望的，我采用了第二种指定tags的方法。MT3.2 开始，MTEntries模板标签新增了tag参数，用于列出具有特定tag的日志。MT中以&quot;@&quot;开头的tags会被隐藏，不会在MTTags 模板标签中列出，但这个标签在其它方面与一个真正的标签没有任何区别，比如可以用来关联主题相似的日志。我为这部分日志指定了一个永远不会被其它日志用到的标签，并加上了&quot;@&quot;作为前缀。然后在边栏增加一下模板代码来生成这部分日志的列表。
</p>
<pre class="code">
&lt;h3&gt;不定期更新|Handy Entries&lt;/h3&gt;
&lt;div class=&quot;module-content&quot;&gt;
&lt;ul&gt;
&lt;MTEntries <span class="emphasis">tag=&quot;@_handy&quot;</span>&gt;
&lt;li&gt;&lt;$MTInclude module=&quot;Entry Link&quot;$&gt;&lt;/li&gt;
&lt;/MTEntries&gt;
&lt;/ul&gt;
&lt;/div&gt; 
</pre>
Template Module Entry Link:<br />
<pre class="code">
&lt;a href=&quot;&lt;$MTEntryPermalink$&gt;&quot; title=&quot;&lt;MTEntryIfTagged&gt;Tags: &lt;MTEntryTags glue=&quot;, &quot;&gt;&lt;$MTTagName$&gt;&lt;/MTEntryTags&gt;&lt;MTElse&gt;No tags&lt;/MTElse&gt;&lt;/MTEntryIfTagged&gt; &quot;&gt;&lt;$MTEntryTitle$&gt;&lt;/a&gt;&nbsp;
</pre>
]]></description>
<link>http://www.aiview.com/2007/01/list_certain_entries_at_sidebar.html</link>
<guid>http://www.aiview.com/2007/01/list_certain_entries_at_sidebar.html</guid>
<category>MT</category>
<pubDate>Mon, 29 Jan 2007 10:13:23 +0700</pubDate>
</item>
<item>
<title>upgrade to TinyMCE 2.09</title>
<description><![CDATA[<a href="http://tinymce.moxiecode.com/">TinyMCE</a>  new version 2.09 came. 
<h4>What&#39;s the new feature?</h4>
<p>
Let&#39;s have a compare with the 2.02.
</p>
<p>
The interface with full features of 2.02
</p>
<p>
<img src="/ref/2007/01/tinymce_2.02.jpg" alt="TinyMCE 2.02 full feature Interface" width="587" height="73" />
</p>
<p>
The interface with full features of 2.09&nbsp;
</p>
<p>
<img src="/ref/2007/01/tinymce_2.09.jpg" alt="TinyMCE 2.09 full feature interface" width="659" height="265" /> 
</p>
<p>
Lots of changes, include: (<span class="emphasis">I only list the changes which are most important for me. I didn&#39;t check the change logs, this info just for reference. </span>)
</p>
<ul>
	<li>New <span class="emphasis">fullscreen mode</span>, I&#39;m editing on this mode, like it very much!<br />
	</li>
	<li>New tags supported</li>
	<ul>
		<li> cite</li>
		<li>abbr</li>
		<li>del</li>
		<li>ins</li>
		<li>acronym</li>
	</ul>
	<li>New development kit, powerful and helpfule!</li>
	<li>Some tiny changes, such as:</li>
	<ul>
		<li>nicer formating on HTML source window.</li>
		<li>won&#39;t link the followed text after a link new generated. </li>
	</ul>
</ul>
<p>
Development kit interface
</p>
<p>
<img src="/ref/2007/01/tinymce_2.09_devkit.jpg" alt="TinyMCE Development kit interface" width="638" height="389" /> 
</p>
<p>
This kit interface is able to collsape and expand.
</p>
<h4>Download and Upgrade in MT</h4>
<p>
Donwload the package file at <a href="http://tinymce.moxiecode.com/download.php">here</a>. Unpackage it and prepare to upgrade. Here&#39;s the steps:
</p>
<ul>
	<li>Backup the old directory and files.</li>
</ul>
<pre class="output">
mt-static\plugins\Ajaxify\tinymce\
\cgi-bin\mt\plugins\Ajaxify\EnhancedEntryEditing.pl (You won&#39;t have and don&#39;t need to backup this file if you don&#39;t use the plugin EnhancedEntryEditing.) 
</pre>
<ul>
	<li>Replace all things in <span class="emphasis">mt-static\plugins\Ajaxify\tinymce\</span> with the new version.</li>
	<li>Open <span class="emphasis">\cgi-bin\mt\plugins\Ajaxify\EnhancedEntryEditing.pl</span> to edit. (no need do this if you don&#39;t have.)</li>
	<li>Comment out all old settings from last installation within: </li>
</ul>
<pre class="code">
&nbsp;&nbsp;&nbsp; settings =&gt; new MT::PluginSettings([
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [&#39;tinymce_config&#39;, { Default =&gt; q{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="emphasis">old setttings here</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }}]
&nbsp;&nbsp;&nbsp; ]),
</pre>
<p>
&nbsp;
</p>
<ul>
	<li>
	Copy new settings from the source(View-&gt;Page Source) of <span class="emphasis">mt-static/plugins/Ajaxify/tinymce/examples/example_full.htm</span> to the place of old settings.</li>
</ul>
<br />
<pre class="code">
&nbsp;&nbsp;&nbsp; settings =&gt; new MT::PluginSettings([
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [&#39;tinymce_config&#39;, { Default =&gt; q{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* old settings here */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="emphasis">new setttings here</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }}]
&nbsp;&nbsp;&nbsp; ]),
</pre>
<ul>
	<li>Make some neccesory changes on the new settings.</li>
</ul>
<pre class="code">
<del>mode : &quot;textareas&quot;,</del>
<ins>mode : &quot;exact&quot;</ins>
<ins>elements : &quot;text,text_more&quot;,</ins>
<del>content_css : &quot;example_full.css&quot;,</del>
<ins>content_css : &quot;/css/extend.css&quot;,</ins>
</pre>
<br />
<ul>
	<li>Save changes, then logon MT management to new an entry(<span class="emphasis">might need a refresh here, F5</span>), the new interface will take effect. <br />
	</li>
	<li><span class="emphasis">Done!</span><br />
	</li>
</ul>
<p>
Here&#39;s the new interface in MT, a little fat for MT got overflow, but not a big problem. Enjoy it!
</p>
<p>
<img src="/ref/2007/01/mt_tinymce_2.09.jpg" alt="TinyMCE 2.09 interface in MT" width="681" height="295" />
</p>
<p>
The full code section in <span class="emphasis">\cgi-bin\mt\plugins\Ajaxify\EnhancedEntryEditing.pl</span> 
</p>
<pre class="code">
settings =&gt; new MT::PluginSettings([
[&#39;tinymce_config&#39;, { Default =&gt; q{
/** This section was used by TinyMCE v2.01
mode : &quot;exact&quot;,
elements : &quot;text,text_more,excerpt&quot;,
theme : &quot;advanced&quot;,
plugins : &quot;iespell, emotions, inlinepopups&quot;,
theme_advanced_blockformats : &quot;p,h1,h2,h3,h4,h5,h6&quot;,
theme_advanced_buttons1 : &quot;formatselect,bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,separator,undo,redo,separator,link,unlink,separator,image,emotions,iespell,help&quot;,
theme_advanced_buttons2 : &quot;&quot;,
theme_advanced_buttons3 : &quot;&quot;,
theme_advanced_toolbar_location : &quot;top&quot;,
theme_advanced_toolbar_align : &quot;left&quot;,
extended_valid_elements : &quot;a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],span[class|align|style]&quot;,
force_p_newlines : true,
relative_urls : false,
remove_script_host : false,
button_tile_map : true,
ask : false,
auto_cleanup_word : true,
theme_advanced_path_location : &quot;bottom&quot;,
theme_advanced_resizing : true,
theme_advanced_resize_horizontal : false,
safari_warning: false,
oninit: &quot;quicktagsHide&quot;
**/
/** This section was used by TinyMCE v2.02
//mode : &quot;textareas&quot;,
mode : &quot;exact&quot;,
elements : &quot;text,text_more&quot;,
//editor_selector : &quot;mceEditor&quot;,
theme : &quot;advanced&quot;,
//plugins : &quot;table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu&quot;,
plugins : &quot;table,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu&quot;,
//theme_advanced_buttons1_add_before : &quot;save,separator&quot;,
theme_advanced_buttons1_add : &quot;fontselect,fontsizeselect&quot;,
theme_advanced_buttons2_add : &quot;separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor&quot;,
theme_advanced_buttons2_add_before: &quot;cut,copy,paste,separator,search,replace,separator&quot;,
theme_advanced_buttons3_add_before : &quot;tablecontrols,separator&quot;,
theme_advanced_buttons3_add : &quot;emotions,iespell,flash,advhr,separator,print&quot;,
theme_advanced_toolbar_location : &quot;top&quot;,
theme_advanced_toolbar_align : &quot;left&quot;,
theme_advanced_path_location : &quot;bottom&quot;,
plugin_insertdate_dateFormat : &quot;%Y-%m-%d&quot;,
plugin_insertdate_timeFormat : &quot;%H:%M:%S&quot;,
extended_valid_elements : &quot;a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]&quot;,
external_link_list_url : &quot;example_data/example_link_list.js&quot;,
external_image_list_url : &quot;example_data/example_image_list.js&quot;,
flash_external_list_url : &quot;example_data/example_flash_list.js&quot;,
content_css : &quot;/css/extend.css&quot;,
theme_advanced_resizing : true,
theme_advanced_resize_horizontal : false,
oninit: &quot;quicktagsHide&quot;
**/
/** This section was used by Tiny MCE v2.09 **/
//mode : &quot;textareas&quot;,
mode : &quot;exact&quot;,
elements : &quot;text,text_more&quot;,
theme : &quot;advanced&quot;,
plugins : &quot;devkit,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras&quot;,
theme_advanced_buttons1_add_before : &quot;save,newdocument,separator&quot;,
theme_advanced_buttons1_add : &quot;fontselect,fontsizeselect&quot;,
theme_advanced_buttons2_add : &quot;separator,insertdate,inserttime,preview,separator,forecolor,backcolor,advsearchreplace&quot;,
theme_advanced_buttons2_add_before: &quot;cut,copy,paste,pastetext,pasteword,separator,search,replace,separator&quot;,
theme_advanced_buttons3_add_before : &quot;tablecontrols,separator&quot;,
theme_advanced_buttons3_add : &quot;emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen&quot;,
theme_advanced_buttons4 : &quot;insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,|,visualchars,nonbreaking&quot;,
theme_advanced_toolbar_location : &quot;top&quot;,
theme_advanced_toolbar_align : &quot;left&quot;,
theme_advanced_path_location : &quot;bottom&quot;,
content_css : &quot;/css/extend.css&quot;,
plugin_insertdate_dateFormat : &quot;%Y-%m-%d&quot;,
plugin_insertdate_timeFormat : &quot;%H:%M:%S&quot;,
extended_valid_elements : &quot;hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]&quot;,
external_link_list_url : &quot;example_link_list.js&quot;,
external_image_list_url : &quot;example_image_list.js&quot;,
flash_external_list_url : &quot;example_flash_list.js&quot;,
media_external_list_url : &quot;example_media_list.js&quot;,
file_browser_callback : &quot;fileBrowserCallBack&quot;,
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : true,
nonbreaking_force_tab : true,
apply_source_formatting : true
}}]
]), 
</pre>
<p>
&nbsp;
</p>
]]></description>
<link>http://www.aiview.com/2007/01/upgrade_to_tinymce_209.html</link>
<guid>http://www.aiview.com/2007/01/upgrade_to_tinymce_209.html</guid>
<category>MT</category>
<pubDate>Sun, 14 Jan 2007 01:33:44 +0700</pubDate>
</item>
<item>
<title>EnhancedEntryEditing plugin settings problem</title>
<description><![CDATA[<p>About&nbsp; <a href="http://plugins.movalog.com/enhancedentryediting/">EnhancedEntryEditing </a> here's an <a href="../../2006/11/mt_upgrade_from_32_to_333.html">article</a>  talked about it in update section.</p><h4>Problem&nbsp;</h4><p>I was trying to change the style sheet for the MT entry editing area of the plugin EnhancedEntryEditing.</p><p>Here's the access to edit the settings in MT plugin management.</p><p><img width="619" height="91" border="0" alt="MT plugin management interface" src="../../ref/2007/01/plugin_settings.jpg" /> <br /></p><p>To click Show Settings will get the settings text and be able to edit then save change. <br />I did the change and the save action did work but got no affection on the MT entry edit interface. It continued to refer to the old style sheet.<br /></p><h4>Solution&nbsp;</h4><p>Finally I track to EnhancedEntryEditing.pl where is the true settings live. I found that the change on MT plugin management don't effect this file in some abnormal reason. So I edited the .pl file directly and it works out.</p><p>EnhancedEntryEditing.pl is locate at: cgi-bin\mt\plugins\Ajaxify</p><h4>Another blockquote Issue</h4><p>I talked about blockquote at this <a href="../../2006/12/refine_and_add_new_features_to_my_web_site.html#22">article</a>, then want to have it in TinyMCE, but I did not found where to insert it into content. After I did some hack work on Format feature I got this tag on the panel of TinyMCE. It's already there, the Indent will insert &lt;blockquote&gt; tag.<br /></p><p><img width="61" height="26" border="0" alt="MT panel section" src="../../ref/2007/01/indent.jpg" /> <br /></p><p>As my new learned, I should only use blockquote tag for real quoted content, not for the format indent. So, I might never use this button.<br /></p><p>&nbsp;</p><p>&nbsp;</p>]]></description>
<link>http://www.aiview.com/2007/01/enhancedentryediting_plugin_settings_problem.html</link>
<guid>http://www.aiview.com/2007/01/enhancedentryediting_plugin_settings_problem.html</guid>
<category>MT</category>
<pubDate>Fri, 12 Jan 2007 16:16:00 +0700</pubDate>
</item>
<item>
<title>Refine and add new features to my web site</title>
<description><![CDATA[<p>
This site disappeared on Internet from the early of this year because
of the server problem. Since then it&#39;s running on my thinkpad locally
for 1 year. Now it&#39;s more like my personal blog. I have to have some
refine work on my blog since I decided to publish it again. Also I
added some new features.
</p>
<p>
Here&#39;s a work log.
</p>
<h4>upgrade MT to version 3.3&nbsp;</h4>
<ul>
	<li>Refer to <a href="../../2006/11/mt_upgrade_from_32_to_333.html" title="Tags: EnhancedEntryEditing, MT, TinyMCE, upgrade ">MT Upgrade  from 3.2 to 3.33</a>&nbsp; </li>
</ul>
<h4>changed to plugined tinymce </h4><br />
<h4>changed title appearance</h4>
<p>
There are 3 level Titles.
</p>
<ol>
	<li>site title</li>
	<li>category and monthly title</li>
	<li>entry title</li>
</ol>
<p>
Each pages have this title structure for search engine friendly, but only display the related title. Others are hided.
</p>
<p>
In the 2nd level pages, the site title is hided. Also in the 3rd level pages, both 1st level and 2nd level titles are hided.
</p>
<p>
Using style:
</p>
<pre class="code">
.subindex-container .index-logo,
.individual-container .index-logo,
.individual-container .subindex-logo {
display: none;
}
</pre>
<h4>gave tags to each entry</h4>
<p>
Give one or more meaningful tags to each entry. The old keywords field is abandoned.&nbsp;
</p>
<h4>neater monthly archive list</h4>
<ul>
	<li>Refer to <a href="../../2006/11/change_monthly_archive_style.html" title="Tags: MT, plugin ">Change  monthly archive style</a>&nbsp; <br />
	</li>
</ul>
<h4>added keywords.js</h4>
<p>
I used <a href="/ref/2006/12/keyword.js" title="Downlaod the Javascript file, Save As">keyword.js</a>  to <a href="../../2005/08/highlight_keywords_with_javascript.html">hilight keywords</a>
which visitor used in search engine for linking in this page in my old
site. I did some simple configure and add it into my blog.
</p>
<p>
I had following settings.&nbsp;
</p>
<pre class="code">
// Configuration:
Keyword = {
<span class="emphasis">hilite: true,</span>
index: false,
<span class="emphasis">refill1: true,</span>
refill2: false,
<span class="emphasis">element1: &#39;search&#39;,</span>
element2: &#39;w&#39;, 
<span class="emphasis">style_name: &#39;hilite&#39;,
style_name_suffix: true,</span>
debug_referrer: &#39;&#39;,
debug_meta: &#39;&#39;
};
</pre>
<h4>added edit link to individual archive</h4>
<p>
Simply to add an edit link to individual entry view, that makes editing entries quicker without going to MT management first.
</p>
<p>
Add following code to individual template:
</p>
<pre class="code">
&lt;a href=&quot;&lt;$MTCGIPath$&gt;mt.cgi?__mode=view&amp;_type=entry&amp;id=&lt;$MTEntryID$&gt;&amp;blog_id=&lt;$MTBlogID$&gt;&quot; title=&quot;edit this entry, only for admin&quot;&gt;Edit&lt;/a&gt;&nbsp;
</pre>
<h4>changed download files location&nbsp;</h4>
<p>
I organized all download files by date instead of by categories. That reduces the length of the file list in a same directory.
</p>
<p>
Current directory structure rule is <span class="emphasis">/ref/year/month/files</span>, exam:
</p>
<pre>
/ref/2006/12/simple.zip
</pre>
<h4>fixed new line problem for entries&nbsp;</h4>
<h4>recheck the broken links</h4>
<p>
I have been using <a href="http://home.snafu.de/tilman/xenulink.html">Xenu</a>
to check broken site links. It&#39;s still a good solution up to now.
Recently, I got another solution that could play part of role of Xenu, <a href="http://www.staggernation.com/mtplugins/CheckLinks/">CheckLinks</a>.
It&#39;s a plugin for MT that only check the links they are within entries.
The reason I picked it up is that It&#39;s easier to have the edit link in
the bad links report by CheckLinks. Here&#39;s a <a href="/check_links.html">report</a>
from my site.&nbsp; For having this feature, I use below Template. This
template is used for checking all entries(maximum 9999 here) in your
blog and printing only the entries with bad links. But rebuilding this
template is as slow as when you check through your blog links with
other tool. So better to <span class="emphasis">uncheck </span>the &quot;<span class="emphasis">Rebuild this template automatically when rebuilding index templates</span>&quot; at template setting if you are using it in Indexes Template.&nbsp; 
</p>
<pre class="code">
&lt;MTEntries lastn=&quot;9999&quot;&gt;
&lt;MTCheckLinks include_local=&quot;1&quot;&gt;
&lt;MTCheckLinksHere&gt;
&lt;$MTEntryBody$&gt;
&lt;$MTEntryExtended$&gt;
&lt;/MTCheckLinksHere&gt;
&lt;MTIfBadLinks&gt;
&lt;dl class=&quot;badlinks&quot;&gt;
&lt;dt&gt;&lt;a href=&quot;&lt;$MTEntryLink$&gt;&quot;&gt;&lt;$MTEntryTitle$&gt;&lt;/a&gt; (&lt;a href=&quot;&lt;$MTCGIPath$&gt;mt.cgi?__mode=view&amp;_type=entry&amp;id=&lt;$MTEntryID$&gt;&amp;blog_id=&lt;$MTBlogID$&gt;&quot; title=&quot;in &lt;$MTCatetoryTitle$&gt;&quot;&gt;edit&lt;/a&gt;) Have bad links:&lt;/dt&gt;
&lt;MTBadLinks <span class="emphasis">load_entries=&quot;1&quot;</span>&gt;
&lt;dd&gt;&lt;$MTBadLinkStatus trim_to=&quot;3&quot;$&gt;: &lt;$MTBadLinkURL$&gt; [&lt;a href=&quot;&lt;$MTBadLinkURL$&gt;&quot;&gt;&lt;$MTBadLinkText$&gt;&lt;/a&gt;]&lt;/dd&gt;
&lt;/MTBadLinks&gt;
&lt;/dl&gt;
&lt;/MTIfBadLinks&gt;
&lt;/MTCheckLinks&gt;
&lt;/MTEntries&gt; 
</pre>
<p>
A note: If you are refering any Entries Tag like &quot;MTEntryTitle&quot; within CheckLinks Tag &lt;MTBadLinks&gt;, you must specify <span class="emphasis">load_entries=&quot;1&quot; </span>otherwise there&#39;s error raising during rebuilding this template.
</p>
<span class="emphasis"></span>
<p>
<span class="emphasis"></span>
</p>
<p>
&nbsp;
</p>
<h4>set up category rss feeds and links</h4>
<ul>
	<li>Refer to: <a href="http://www.lindamoran.net/searchwifey/MT3.2categoryRSS.html">Step by step instructions for MT Category RSS feeds</a><strong><em>&nbsp; <br />
	</em></strong></li>
</ul>
<h4>managed external links by blogroll</h4>
<p>
I downloaded a new plugin <a href="http://plugins.movalog.com/mt-blogroll/">Blogroll</a>  for managing my links.&nbsp;
</p>
<p>
Use Blogroll I could manage and group my links, and publish them in template.
</p>
<p>
Using following code in template:&nbsp;
</p>
<pre class="code">
&lt;MTBlogrollCategories&gt;&nbsp;&nbsp; 
&lt;h3&gt;&lt;$MTBlogrollCategoryLabel$&gt;&lt;/h3&gt; 
&lt;ul&gt;&lt;MTBlogrollLinks&gt; 
&lt;li&gt;&lt;a href=&quot;&lt;$MTBlogrollLinkURI$&gt;&quot; title=&quot;&lt;MTBlogrollLinkDesc&gt;&quot;&lt;MTIfNonEmpty tag=&quot;BlogrollLinkRel&quot;&gt; rel=&quot;&lt;MTBlogrollLinkRel&gt;&quot;&lt;/MTIfNonEmpty&gt; &lt;MTIfNonEmpty tag=&quot;BlogrollLinkTarget&quot;&gt;target=&quot;&lt;MTBlogrollLinkTarget&gt;&quot;&lt;/MTIfNonEmpty&gt;&gt;&lt;$MTBlogrollLinkName$&gt;&lt;/a&gt;&lt;/li&gt; 
&lt;/MTBlogrollLinks&gt;&lt;/ul&gt; 
&lt;/MTBlogrollCategories&gt;&nbsp;
</pre>
<h4>related tags on tag search&nbsp;</h4>
<p>
I downloaded a new plugin <a href="http://code.as-is.net/wiki/TagSupplementals_Plugin">TagSupplymentals</a> that brings much features on tags. I use <a href="http://code.as-is.net/wiki/TagSupplementals_Plugin#head-606d1f538bdcb4e579c48d949e1d1676a0b3e24c">MTRelatedEntries</a> and <a href="http://code.as-is.net/wiki/TagSupplementals_Plugin#head-349bd8a6014b4a621a3813bdbd16b433373591ce">MTRelatedTags</a>.
</p>
<p>
Using following code in template:
</p>
<pre class="code">
&lt;ul&gt;
&lt;h3&gt;Related Entries&lt;/h3&gt;
&lt;MTRelatedEntries lastn=&quot;5&quot;&gt;
&lt;li&gt;&lt;$MTInclude module=&quot;Entry Link&quot;$&gt;&lt;/li&gt;
&lt;/MTRelatedEntries&gt;
&lt;/ul&gt; 
</pre>
&nbsp;
<pre class="code">
&lt;ul&gt;
&lt;h3&gt;Related Tags&lt;/h3&gt;
&lt;MTEntryTags&gt;
&lt;MTRelatedTags&gt;
&lt;li&gt;&lt;a xhref=&quot;&lt;$MTTagSearchLink$&gt;&quot;&gt;&lt;$MTTagName$&gt;&lt;/a&gt; (&lt;$MTTagCount$&gt;)&lt;/li&gt;
&lt;/MTRelatedTags&gt;
&lt;/MTEntryTags&gt;
&lt;/ul&gt;
</pre>
<p>
&nbsp;
</p>
<h4>related entries by tags</h4>
<p>
See above.&nbsp;
</p>
<h4>more clear search result</h4>
<p>
On the search result list, as default only show the entry title and
entry summary. So the searcher could have an overview on all search
result. If he wants more info about the entry there&#39;s a link to expand
the entry area to show entry body.
</p>
<p>
Template:
</p>
<pre class="code">
&lt;MTEntriesHeader&gt;
&lt;!--start #top-alpha--&gt;
&lt;div id=&quot;top-alpha&quot;&gt;
<span class="emphasis">&lt;label id=&quot;hidebodybar&quot; class=&quot;hidbodybar&quot;&gt;&lt;/label&gt;</span>
&lt;!--end #top-alpha--&gt;
&lt;/div&gt;
&lt;/MTEntriesHeader&gt;
&lt;!--start #entry~--&gt;
&lt;div class=&quot;entry&quot; id=&quot;entry&lt;$MTEntryID pad=&quot;1&quot;$&gt;&quot;&gt;
<span class="emphasis">&lt;a name=&quot;a&lt;$MTEntryID pad=&quot;1&quot;$&gt;&quot; /&gt;
</span>
&lt;!--start #top-entry~--&gt;
&lt;div class=&quot;top-entry&quot; id=&quot;top-entry&lt;$MTEntryID pad=&quot;1&quot;$&gt;&quot;&gt;
<span class="emphasis">&lt;label class=&quot;hidebodybar&quot; id=&quot;hidebodybar&lt;$MTEntryID pad=&quot;1&quot;$&gt;&quot;&gt;&lt;/label&gt;</span>
&lt;!--end #top-entry~--&gt;
&lt;/div&gt;
&lt;h3 class=&quot;entryheader&quot; id=&quot;a&lt;$MTEntryID pad=&quot;1&quot;$&gt;&quot;&gt;&lt;a href=&quot;&lt;$MTEntryPermalink$&gt;&quot;&gt;&lt;$MTEntryTitle$&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;!--start #entryinfo~--&gt;
&lt;div class=&quot;entryinfo&quot; <span class="emphasis">id=&quot;entryinfo&lt;$MTEntryID pad=&quot;1&quot;$&gt;&quot;</span>&gt;
&lt;MTIfOne name=&quot;Category Archive&quot;&gt;
&lt;p class=&quot;subtitle&quot;&gt;&lt;$MTEntryDate format=&quot;%x&quot;$&gt;&lt;/p&gt;
&lt;MTElse&gt;
&lt;p class=&quot;subtitle&quot;&gt;In &lt;a href=&quot;&lt;$MTEntryLink archive_type=&quot;Category&quot;$&gt;&quot;&gt;&lt;$MTEntryCategory$&gt;&lt;/a&gt;, &lt;$MTEntryDate format=&quot;%x&quot;$&gt;&lt;/p&gt;
&lt;/MTElse&gt;
&lt;/MTIfOne&gt;
&lt;!--end #entryinfo~--&gt;
&lt;/div&gt;
&lt;!--start #entrysummary~--&gt;
&lt;div class=&quot;entrysummary&quot;<span class="emphasis"> id=&quot;entrysummary&lt;$MTEntryID pad=&quot;1&quot;$&gt;&quot;</span>&gt;
&lt;$MTEntryBody convert_breaks=&quot;0&quot; words=&quot;16&quot;$&gt;...
&lt;!--end #entrysummary~--&gt;
&lt;/div&gt;
&lt;!--start #entrybody~--&gt;
&lt;div class=&quot;entrybody&quot; <span class="emphasis">id=&quot;entrybody&lt;$MTEntryID pad=&quot;1&quot;$&gt;&quot;</span>&gt;
&lt;$MTEntryBody convert_breaks=&quot;0&quot;$&gt;
&lt;MTEntryIfExtended&gt;&lt;p&gt;继续阅读 &quot;&lt;a href=&quot;&lt;$MTEntryPermalink$&gt;#more&quot;&gt;&lt;$MTEntryTitle$&gt;&lt;/a&gt;&quot; 的剩余内容&lt;/p&gt;&lt;/MTEntryIfExtended&gt;
&lt;!--end #entrybody~--&gt;
&lt;/div&gt;
&lt;!--start #entryfooter~--&gt;
&lt;div class=&quot;entryfooter&quot; <span class="emphasis">id=&quot;entryfooter&lt;$MTEntryID pad=&quot;1&quot;$&gt;&quot;</span>&gt;
&lt;MTEntryIfTagged&gt;&lt;p&gt;标签 Tags: 其它与&lt;MTEntryTags glue=&quot;, &quot;&gt;&lt;a href=&quot;&lt;$MTTagSearchLink$&gt;&quot;&gt;&lt;$MTTagName$&gt;&lt;/a&gt; (&lt;$MTTagCount$&gt;)&lt;/MTEntryTags&gt; 相关的话题&lt;/p&gt;&lt;/MTEntryIfTagged&gt;
&lt;p class=&quot;posted&quot;&gt;
Posted by &lt;$MTEntryAuthorUsername$&gt; at &lt;$MTEntryDate format=&quot;%X&quot;$&gt;
&lt;MTEntryIfAllowComments&gt; | &lt;a href=&quot;&lt;$MTEntryPermalink archive_type=&quot;Individual&quot;$&gt;#comments&quot;&gt;Comments (&lt;$MTEntryCommentCount$&gt;)&lt;/a&gt;&lt;/MTEntryIfAllowComments&gt;
&lt;MTEntryIfAllowPings&gt; | &lt;a href=&quot;&lt;$MTEntryPermalink archive_type=&quot;Individual&quot;$&gt;#trackbacks&quot;&gt;TrackBack (&lt;$MTEntryTrackbackCount$&gt;)&lt;/a&gt;&lt;/MTEntryIfAllowPings&gt;
| &lt;a href=&quot;&lt;$MTCGIPath$&gt;mt.cgi?__mode=view&amp;_type=entry&amp;id=&lt;$MTEntryID$&gt;&amp;blog_id=&lt;$MTBlogID$&gt;&quot; title=&quot;edit this entry, only for admin&quot;&gt;Edit&lt;/a&gt;
&lt;/p&gt;
&lt;!--end #entryfooter~--&gt;
&lt;/div&gt;
&lt;!--end #entry--&gt;
&lt;/div&gt;
</pre>
<p>
Javascript: <a href="/hide-body.js">hide-body.js</a> 
</p>
<h4>flexible style sheet</h4>
<p>
I had this new bar on the top of page.
</p>
<p>
<img src="../../ref/2006/12/change_style.gif" border="0" alt="text bar for changing style" width="300" height="100" />
</p>
<p>
It makes possible to switch different style sheet on current page by one click.
</p>
<p>
For doing this, needs <a href="../../switch-css.js">switch-css.js</a>, and the defination in the head.
</p>
<pre class="code">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;&lt;$MTBlogURL$&gt;css/screen.css&quot; media=&quot;screen&quot; title=&quot;BlockStyle&quot; /&gt;
&lt;link rel=&quot;alternate stylesheet&quot; type=&quot;text/css&quot; href=&quot;&lt;$MTBlogURL$&gt;css/screen-clearstyle.css&quot; media=&quot;screen&quot; title=&quot;ClearStyle&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;&lt;$MTBlogURL$&gt;switch-css.js&quot;&gt;&lt;/script&gt;
</pre>
And the label tag with ID definition in the page. The css links would be generated by the .js above dynamically.<br />
<pre class="code">
&lt;label id=&quot;switchcssbar&quot;&gt;&lt;/label&gt;
</pre>
<p>
The code refer to:
</p>
<ul>
	<li> <a href="http://www.alistapart.com/articles/alternate">Alternative Style: Working With Alternate Style Sheets</a></li>
	<li><a href="http://www.codebit.cn/pub/html/javascript/tip/css_switcher/">Javascript&nbsp;切换页面&nbsp;CSS&nbsp;样式</a></li>
</ul>
<h4>tested none-css appearance&nbsp;</h4>
<p>
To see what my blog is like without style sheet, click below link. If you want to <span class="emphasis">change it back</span>, choose the <span class="emphasis">block Style</span> links on the top of any page. I&#39;m ready to change this site as <a href="#" title="NoneStyle" onclick="javascript:Switchcss.setActiveStyleSheet(this.title)">None Style</a>   
</p>
<h4>tested printable view</h4>
<p>
To see how it works, select &quot;File - Print Preview&quot; in your Internet Browser. 
</p>
<p>
The format is defined in <a href="../../css/print.css">print.css</a> .
</p>
<h4>made the old site work</h4>
<p>
Made some neccesary changes on my <a href="../../v_3">old site</a>  for showing it in sub folder well.
</p>
<h4>change to mysql database</h4>
<ul>
	<li>Refer to: <a href="../../2006/11/convert_mt_from_berkeley_db_to_mysql.html" title="Tags: MT, MySQL, mysql ">Convert  MT from Berkeley DB to MySQL</a>&nbsp; <br />
	</li>
</ul>
<h4>power editing basename&nbsp;</h4>
<p>
I think this would be helpful, lots of people want to have this feature.&nbsp;
</p>
<ul>
	<li>Refer to: <a href="../../2006/11/power_editing_basename.html" title="Tags: basename, MT ">Power editing  basename</a>&nbsp; <br />
	</li>
</ul>
<h4>add style to preformatted tag &lt;pre&gt;</h4>
<p>
I used <span class="emphasis">&lt;pre&gt;</span> tag for several cases: 
</p>
<ul>
	<li>programming code (exam: javascripts)<br />
	</li>
	<li>command (exam: unix shell commands)</li>
	<li>output (exam: screen output of a command)</li>
	<li>refererence (exam: a short paragraph from other blog)</li>
</ul>
<p>
But they do have different requirements for showing up. So I add several class styles for the tag.
</p>
<ul>
	<li>.code</li>
	<li>.cmd</li>
	<li>.output<br />
	</li>
	<li>.refer (with word wrap)</li>
</ul>
<p>
For the .refer class style, I referred to <a href="http://www.ashchan.com/blog/archive/2006/12/04/wrapping-the-pre-tag.aspx" title="Title of this entry.">pre标签自动换行方案</a>.
</p>
<p>
Update: Read an article <a href="http://blog.tn38.net/archives/2005/05/what_are_semant.html">What are semantics?</a>, learned that I should use <span class="emphasis">&lt;blockquote&gt;</span> tag to wrap the resource that I refer to. So I need to use &lt;blockquote&gt; tag instead of class style .refer. 
</p>
<h4>upgrade to TinyMCE 2.09</h4>
<ul>
	<li>Refer to <a href="../../2007/01/test.html">upgrade to TinyMCE 2.09</a>&nbsp; <br />
	</li>
</ul>
<h4>Refined Page structure</h4>
<ul>
	<li>Refer to <a href="http://www.aiview.com/2007/01/refine_web_page_structure.html">Refine web page structure</a>&nbsp;</li>
</ul>
<h4>Refinced CSS</h4>
<p>
I split my css file as multi-level and use import keyword to link them up. I have following structure. The <a href="/css/base.css">base.css</a> 
and <a href="/css/extend.css">extend.css</a>  is used by each style sheet. The difference is that the extend.css
is also refered by TinyMCE in MT. About TinyMCE please read <a href="http://www.aiview.com/2007/01/upgrade_to_tinymce_209.html">this article</a> . 
</p>
<p>
base.css&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extend.css<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \&nbsp;&nbsp;&nbsp; /<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="/css/screen.css">screen.css</a> <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="/css/screen-linestyle.css">screen-linestyle.css</a> <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="/css/screen-clearstyle.css">screen-clearstyle.css</a> 
</p>
<p>
I <a href="http://www.clagnut.com/blog/1287/">reset padding and margin</a>  as 0 in my base.css that makes crossing browsers development easier. Here&#39;s a style list about <a href="http://www.css-zibaldone.com/the-css-switch-project/december-2006/default-style-sheet-for-html-elements/style.html">Firefox 1.5 default style sheet for HTML elements</a> for reference.
</p>
<p>
I tried to have more comfortable color for pages. Here are some links would be helpful on this. <a href="http://book.chinaz.com/CSS/css_2/css.html">The safe 216 web colors</a>, a <a href="http://gene7299.spaces.live.com/Blog/cns!1pAcW0T8ZlSwoXd4sFC7C_1A!5516.entry">list</a>  of online colour tool. 
</p>
<p>
&nbsp;
</p>
<h4>
Disable listing directory</h4>
<p>
<br />
Create a file &quot;.htaccess&quot; at the root path of web site and have following line: 
</p>
<pre class="emphasis">
Options All -Indexes 
</pre>
<h4>Rewrite url for old site</h4>
<p>
<br />
Add below lines to /.htaccess. 
</p>
<pre class="code">
RewriteEngine On
RewriteRule ^archives/([0-9]+/[0-9]+) $1
RewriteRule ^archives/(jeet_kune_do|outdoors) $1
RewriteRule ^archives/study_notes/(web|linux) $1
RewriteRule ^hobbies/(outdoors) $1
RewriteRule ^hobbies/ham/ amateur_radio
RewriteRule ^hobbies/sbenefit/ society_benefit
RewriteRule ^notes/*(db2|linux)* $1
RewriteRule ^notes/[a-z0-9\_\-]+.htm$ db2
RewriteRule ^archives/study_notes/[a-z0-9\_\-]+.html$ db2&nbsp;
</pre>
<pre>
A little help on expression I used.&nbsp;
</pre>
<ul>
	<li>^ is maching the begin of aline.</li>
	<li>$ is mathing the end of a line.&nbsp;</li>
	<li>$n is a reference for the expression within (), also could have $1, $2..., as I know, $0 should be the entire of $n.</li>
	<li>| is the OR relationship.</li>
	<li>+ match at least one time.</li>
</ul>
<pre>
Had <a href="http://www.ibf.com.ru/viewarticle.php?id=614">this article</a>  for reference.&nbsp;
</pre>
]]></description>
<link>http://www.aiview.com/2006/12/refine_and_add_new_features_to_my_web_site.html</link>
<guid>http://www.aiview.com/2006/12/refine_and_add_new_features_to_my_web_site.html</guid>
<category>MT</category>
<pubDate>Fri, 29 Dec 2006 10:05:00 +0700</pubDate>
</item>
<item>
<title>Related entries on tags</title>
<description><![CDATA[<p>I had a plugin that allows having a related entries list in the same category. It's not very helpfule for visitors as you have many entries in a category.</p><p>Tags is supported since MT 3.3. We may want to have a related entries list based on tags on the current entry. <a href="http://as-is.net/wiki/TagSupplementals_Plugin">TagSupplementals</a>  plugin is doing that. It provides a set of features for tags supplement. We're using one of them.<br /></p>]]></description>
<link>http://www.aiview.com/2006/11/related_entries_on_tags.html</link>
<guid>http://www.aiview.com/2006/11/related_entries_on_tags.html</guid>
<category>MT</category>
<pubDate>Wed, 29 Nov 2006 14:08:39 +0700</pubDate>
</item>
<item>
<title>Change monthly archive style</title>
<description><![CDATA[<p>The too long monthly archive list get bad-looking.</p><p>Download a new plug-in <a href="http://code.appnel.com/mt-archive-dateheader">mt-archive-dateheader</a> to have a neat calendar for monthly archive like this:</p><p><img width="170" height="206" border="1" alt="kalsey-dates.gif" class="floatimgleft" src="http://www.learningmovabletype.com/images/kalsey-dates.gif" /></p>  <p>&nbsp;</p><p>Change the template to</p><pre class="code">  &lt;h2&gt;按月归档|By Month&lt;/h2&gt;<br /><br />  &lt;a class=&quot;skip&quot; xhref=&quot;http://blog.alex.com/cgi-bin/mt/mt.cgi#endbymonth&quot;&gt;Skip over by month&lt;/a&gt;<br /><br />  &lt;MTArchiveList archive_type=&quot;Monthly&quot;&gt;<br />  &lt;MTArchiveDateHeader&gt;<br />    &lt;p&gt;&lt;b&gt;&lt;MTArchiveDate format=&quot;%Y&quot;&gt;&lt;/b&gt;&lt;/p&gt;<br />  &lt;/MTArchiveDateHeader&gt;<br />  &lt;a xhref=&quot;&lt;$MTArchiveLink$&gt;&quot;&gt;&lt;MTArchiveDate format=&quot;%B&quot;&gt;&lt;/a&gt;&lt;span class=&quot;num&quot;&gt;&lt;$MTArchiveCount$&gt;&lt;/span&gt; <br />  &lt;/MTArchiveList&gt;<br />  &lt;p&gt;&lt;/p&gt;<br />  <br />  &lt;a class=&quot;skip&quot; id=&quot;endbymonth&quot;&gt;&lt;/a&gt;<br /><br /></pre>]]></description>
<link>http://www.aiview.com/2006/11/change_monthly_archive_style.html</link>
<guid>http://www.aiview.com/2006/11/change_monthly_archive_style.html</guid>
<category>MT</category>
<pubDate>Fri, 24 Nov 2006 17:02:04 +0700</pubDate>
</item>
<item>
<title>Convert MT from Berkeley DB to MySQL</title>
<description><![CDATA[<p>最近决定把MT的后台数据从Berkeley的文件DB转到MySQL。原因之一是使用关系数据库可以获得更多的灵活性，比如运行一条sql来变更 所有entry的某一个属性；另外一个原因是为了提前熟悉一下这个数据库，牙牙网站使用虚拟主机，DreamHost提供的数据库是MySQL，而我从前 主要使用了SQL Server，Oracle和DB2，Postgresql也只了解了一点，而MySQL则几乎没有接触过。</p><p>下载了5.0.27安装文件，安装顺利，使用了第一个默认端口3306，UTF-8的数据库字符集。</p><p>安装完成，运行了命令行客户端，输入help，给出的帮助命令不多，也没见到有关数据库创建的命令，便查了安装的帮助文件，组织的还算不错，很齐全，很快找到相关的命令：</p><pre class="cmd">查看已有数据库<br />show databases;<br /><br />连接数据库 test<br />use test;<br /><br />创建数据库 mt<br />create database mt;</pre><p>接下来寻找把已有DB转化到MySQL的方法，很快找到一个第三方的工具<a href="http://as-is.net/hacks/2005/07/mt_db_convert_cgi_mt_database_converter.html">mt-db-convert.cgi</a> ，可以实现MT支持的几种不同的DB之间的转换。</p><p>下载回来放到cgi-bin的mt目录，在浏览器访问运行，输入新创建的MySQL数据库名称mt，用户名root，密码，主机填入localhost，开始Convert。转换过程很快就完成了，不到1分钟，没有出现错误提示，转换信息如下：</p><pre class="output">mt-db-convert.cgi($Rev: 173 $): Converting your MT data between DB engines (for MT 3.2)<br />                                                                                                              <br />Loading database schema...                                                                                    <br />                                                                                                              <br />Loading data...                                                                                               <br />MT::Author                                                                                                    <br />.                                                                                                             <br />(1 objects saved.)                                                                                            <br />                                                                                                              <br />MT::Blog                                                                                                      <br />..                                                                                                            <br />(2 objects saved.)                                                                                            <br />                                                                                                              <br />MT::Trackback                                                                                                 <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......                                                                                 <br />(327 objects saved.)                                                                                          <br />                                                                                                              <br />MT::Category                                                                                                  <br />.......... .......... .......... .......... ..........                                                        <br />(50 objects saved.)                                                                                           <br />                                                                                                              <br />MT::Comment                                                                                                   <br />..                                                                                                            <br />(2 objects saved.)                                                                                            <br />                                                                                                              <br />MT::Entry                                                                                                     <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... ....                                                                                               <br />(514 objects saved.)                                                                                          <br />                                                                                                              <br />MT::IPBanList                                                                                                 <br />                                                                                                              <br />(0 objects saved.)                                                                                            <br />                                                                                                              <br />MT::Log                                                                                                       <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......                                                                      <br />(437 objects saved.)                                                                                          <br />                                                                                                              <br />MT::Notification                                                                                              <br />                                                                                                              <br />(0 objects saved.)                                                                                            <br />                                                                                                              <br />MT::Permission                                                                                                <br />....                                                                                                          <br />(4 objects saved.)                                                                                            <br />                                                                                                              <br />MT::Placement                                                                                                 <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......... .......... .......... .......... .......... .......... .......... .......... <br />.......... .......... .......                                                                                 <br />(527 objects saved.)                                                                                          <br />                                                                                                              <br />MT::Template                                                                                                  <br />.......... .......... .......... .......... .......... .......... .......... .......... ...                   <br />(83 objects saved.)                                                                                           <br />                                                                                                              <br />MT::TemplateMap                                                                                               <br />..........                                                                                                    <br />(10 objects saved.)                                                                                           <br />                                                                                                              <br />MT::TBPing                                                                                                    <br />                                                                                                              <br />(0 objects saved.)                                                                                            <br />                                                                                                              <br />MT::Session                                                                                                   <br />.......... .......... .........                                                                               <br />(29 objects saved.)                                                                                           <br />                                                                                                              <br />MT::PluginData                                                                                                <br />                                                                                                              <br />(0 objects saved.)                                                                                            <br />                                                                                                              <br />MT::Config                                                                                                    <br />.                                                                                                             <br />(1 objects saved.)                                                                                            <br />                                                                                                              <br />MT::FileInfo                                                                                                  <br />                                                                                                              <br />(0 objects saved.)                                                                                            <br />                                                                                                              <br />                                                                                                              <br />Done copying data from DBM to DBI::mysql! All went well.                                                      <br />                                                                                                              <br />Your recommended setting                                                                                      <br />-------------------------------------                                                                         <br /># DataSource R:/SITE/mt-db                                                                                    <br />ObjectDriver DBI::mysql                                                                                       <br />Database mt                                                                                                   <br />DBUser root                                                                                                   <br />DBHost localhost                                                                                              <br />DBPassword comein                                                                                             <br />-------------------------------------                                                                         </pre><p>然后修改mt-config.cgi文件，把数据源改成MySQL。&nbsp;</p><p>再次访问MT，看起来一切正常，甚至原有的session都没有丢掉，只是后台使用的数据已经改变了位置。<br />不过发现了中文乱码问题，Google到了<a href="http://www.kingda.org/archives/kingda/2006/04/mt32_1.html">这个方法</a> ，按文修改后，需要再次执行mt-db-convert.cgi，把数据重新导入MySQL，再访问MT，乱码没有了，所有中文显示正常。 </p><p>转换后又发现了一个新的问题，原DB中的Tags全部丢失，原因是mt-db-convert.cgi仅支持到MT 3.1，3.3的新功能带来的数据变化可能还会有其它信息丢失。</p><blockquote>NOTE<br /><br />This script is compatible with Movable Type version 3.1x.  I didn't test it at any other versions. </blockquote><p><br />其实MT自身已经提供了转换工具mt-db2sql.cgi，与mt.cgi在同一目录当中。使用方法是，安装好MySQL数据库服务，并创建好用于MT的DB，将MySQL数据库的配置信息加入mt-config.cgi，并同时保留原Berkeley DB的路径配置，即保持两种DB的配置同时生效，然后通过浏览器运行mt-db2sql.cgi，转换会自动开始，显示如下信息：</p><pre class="output">Loading database schema...<br /><br />Loading data...<br />MT::Author<br />    1<br /><br />MT::Blog<br />    1<br />    3<br /><br />MT::Trackback <br />...<br /><br />Done copying data from Berkeley DB to your SQL database! All went well.<br /><br /></pre><p>确认转换成功后，再修改mt-config.cgi，注释掉Berkeley DB的配置即可。</p><p>这里是官方的帮助文档：</p><ul><li><a href="http://www.sixapart.com/movabletype/kb/databases/database_conver.html">Databases: Database Conversion</a></li></ul><p>&nbsp;</p>]]></description>
<link>http://www.aiview.com/2006/11/convert_mt_from_berkeley_db_to_mysql.html</link>
<guid>http://www.aiview.com/2006/11/convert_mt_from_berkeley_db_to_mysql.html</guid>
<category>MT</category>
<pubDate>Thu, 23 Nov 2006 02:35:19 +0700</pubDate>
</item>
<item>
<title>Power editing basename</title>
<description><![CDATA[<p>There's no way to batch edit basename in MT, even no a plugin for this.</p><p>I hacked into .tmpl and .pm files to implement the feature based on MT version 3.33.<br /></p><ul><li>\cgi-bin\mt\tmpl\cms\entry_table.tmpl <br /></li></ul><p>line 40 add:<br /></p><pre class="code">&lt;TMPL_IF NAME=IS_POWER_EDIT&gt;<br />&lt;th id=&quot;en-basename&quot;&gt;&lt;MT_TRANS phrase=&quot;Basename&quot;&gt;&lt;/th&gt;<br />&lt;/TMPL_IF&gt; </pre><p>line 133 add:&nbsp;</p><pre class="code">&lt;TMPL_IF NAME=IS_POWER_EDIT&gt;<br />&lt;td&gt;<br />&lt;input type=&quot;hidden&quot; name=&quot;basename_manual_&lt;TMPL_VAR NAME=ID&gt;&quot; id=&quot;basename_manual_&lt;TMPL_VAR NAME=ID&gt;&quot; value=&quot;0&quot; /&gt;<br />&lt;input type=&quot;text&quot; name=&quot;basename_&lt;TMPL_VAR NAME=ID&gt;&quot; id=&quot;basename_&lt;TMPL_VAR NAME=ID&gt;&quot; value=&quot;&lt;TMPL_VAR NAME=BASENAME&gt;&quot; onchange=&quot;setElementValue('basename_&lt;TMPL_VAR NAME=ID&gt;', dirify(this.value));setElementValue('basename_manual_&lt;TMPL_VAR NAME=ID&gt;', 1)&quot; /&gt;<br />&lt;/td&gt;<br />&lt;/TMPL_IF&gt; </pre><p>&nbsp;</p><ul><li>\cgi-bin\mt\lib\MT\App\CMS.pm</li></ul><p>line 6468 add:<br /></p><pre class="code">        my $basename = $q-&gt;param('basename_' . $id);<br />        if ( $basename &amp;&amp; $q-&gt;param('basename_manual_' . $id)) {<br />            $entry-&gt;basename($basename);<br />        } elsif ( !$basename ) {<br />            $entry-&gt;basename(MT::Util::make_unique_basename($entry));<br />        }</pre><ul><li>\mt-static\style.css add(optional):</li></ul><p>line 1107 add:</p><pre class="code">&nbsp;#list-entry table #en-basename { width: 20% }</pre><p>&nbsp;</p>]]></description>
<link>http://www.aiview.com/2006/11/power_editing_basename.html</link>
<guid>http://www.aiview.com/2006/11/power_editing_basename.html</guid>
<category>MT</category>
<pubDate>Mon, 20 Nov 2006 06:35:27 +0700</pubDate>
</item>


</channel>
</rss>