#!/usr/local/bin/php タグアーカイブの作成:IGALOG-R

IGALOG-R

現在こちらのサイトは休止中。http://igalog.netでXOOPSを使って再開中。

タグアーカイブの作成

Tag:
MovableTypeTechnoratiでMovableTypeを検索track wordでMovableTypeを検索
TagwireTechnoratiでTagwireを検索track wordでTagwireを検索
mt-plusTechnoratiでmt-plusを検索track wordでmt-plusを検索
TaggingTechnoratiでTaggingを検索track wordでTaggingを検索
pluginTechnoratiでpluginを検索track wordでpluginを検索

前エントリーで導入したTagwireプラグインを使って、そのタグをつけた記事だけを抽出したアーカイブを作成する方法があったので、それを実装してみた。

このエントリーでは、Tagwire PluginをMT-XSearchと組み合わせて動的タグアーカイブを実現する方法とその高速化手法について述べます。
記事の上部にあるタグフィールドでそこにあるタグの文字リンクをクリックするとアーカイブへ。
Technoratiで検索アイコンをクリックすると、Technoratiで検索するようにした。

導入は上記のリンク先を見ていただければ全てできる。
とりあえずうちのサイトの再構築等の参考にカスタマイズ内容も含めて全て書いておく。

0.事前準備

もちろんだが、Tagwireプラグインが実装済みのことが前提条件である。
入ってない場合は、こちらの記事を読んで導入してください。 

1.ファイルのダウンロード

mt-plusというプラグインをダウンロードする。

→ mt-plusダウンロードページ

尚、この記事はVer.1.01をベースに書かれている。
バージョンアップしていると少し内容が違うかもしれないのであしからず。

2.ファイルを書き換える

  • mt-xsearch.cgi
  • plugins/mt-xsearch.pl

以上の2ファイルが日本語処理に問題があるらしいので書き換えてやる。
Ogawaさんのところではパッチファイルがどうのと書いていたが、パッチの当て方なんてわからんのでどうすればいいのかと思って途方に暮れかけましたよ。内容をよく見たらちょっと書き換えるだけっぽかったので、手動でしちゃいました。

mt-xsearch.cgi

44行目付近にある 

print $q->header.$out;

これを 

my $charset = $mt->{cfg}->PublishCharset;
print $q->header(-charset=>$charset).$out;

と書き換えてやる

plugins/mt-xsearch.pl

69行目付近にある 

my $current = $offset / $limit + 1;

という記述があるので、これを 

my $current = $limit ? ($offset / $limit + 1) : 1;

と書き換えてやる。 

3.テンプレート作成

「XSearch Tagwire」という名前のテンプレートモジュールを作ります。
中身はOgawaさんのところがシンプルですが、うちの場合はDreamWeaver風テンプレートを利用していますので、それに合わせる形でカスタマイズしています。少しずつさわるかもしれませんが、とりあえず記事を書いた当初のテンプレートはこんな感じになります。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<$MTPublishCharset$>" />
<title>タグサーチ:<$MTBlogName encode_html="1"$></title>
<link rel="stylesheet" href="<$MTBlogURL$>styles-site.css" type="text/css" />
<script language="JavaScript" type="text/JavaScript" src="<$MTBlogURL$>macromedia2/ShowMore.js"></script>
<link href="<$MTBlogURL$>ArekorePopup/ArekorePopup.css" rel="stylesheet" type="text/css">
<script src="<$MTBlogURL$>ArekorePopup/ArekorePopup.js" type="text/javascript"></script>
</head>
<body>
<div id="row1">
<div id="siteName">
<h1><a href="<$MTBlogURL$>"><$MTBlogName encode_html="1"$></a></h1>
</div>
<div id="utility"><$MTBlogDescription$></div>
<div id="globalNav">
<img alt="" src="<$MTBlogURL$>macromedia2/gblnav_left.gif" height="32" width="4" id="gnl" />
<img alt="" src="<$MTBlogURL$>macromedia2/glbnav_right.gif" height="32" width="4" id="gnr" />
<form id="search" method="get" action="<$MTCGIPath$>mt-xsearch.cgi">
<input type="hidden" name="blog_id" value="<$MTBlogID$>" />
<input type="hidden" name="search_key" value="Tagwire" />
<input  type="text" name="search" size="20" value="<$MTSearchString decode_url="1" encode_html="1"$>" />
<input type="submit" value="タグ検索" />
</form>
</div>
<!-- end globalNav -->
</div>
<!-- end row1 -->
<div id="pagecell1">
<!--pagecell1-->
<img alt="" src="<$MTBlogURL$>macromedia2/tl_curve_white.gif" height="6" width="6" id="tl" />
<img alt="" src="<$MTBlogURL$>macromedia2/tr_curve_white.gif" height="6" width="6" id="tr" />
<div id="col1">
<div class="story">
<MTSearchResults>
<MTSearchHeader>
<$MTSearchResultCount$> 件がヒットしました。
</MTSearchHeader>
<div class="story-head" id="a<$MTEntryID pad="1"$>">
<h2><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></h2>
</div>
<div class="story">
<$MTEntryExcerpt convert_breaks="1"$>
<div class="posted">
Posted by <$MTEntryAuthor$> at <a href="<$MTEntryPermalink valid_html="yes"$>"><$MTEntryDate format="%X"$></a>
</div>
</div>
<MTSearchFooter>
<p>検索したタグは<em><$MTSearchString decode_url="1"$></em>です。</p>
</MTSearchFooter>
</MTSearchResults>
<MTNoSearch><p>No search performed.</p></MTNoSearch>
<MTNoSearchResults><p>Nothing found.</p></MTNoSearchResults>
</div>
</div>
<div id="siteInfo">
<a href="http://www.macromedia.com/jp/software/dreamweaver/"><img src="<$MTBlogURL$>macromedia2/mwm_dwmx_88_31.gif" alt="Made with dreamweaver" width="88" height="31" border="0" /></a><a href="http://www.macromedia.com/jp/software/fireworks/"><img src="<$MTBlogURL$>macromedia2/mwm_fwmx_88_31.gif" alt="Made with fireworks" width="88" height="31" border="0" /></a><a href="http://www.movabletype.org/"><img src="<$MTBlogURL$>macromedia2/movabletype.gif" alt="Powered by Movable Type <$MTVersion$>" width="137" height="32" border=0></a><a href="http://wandering-wind.jp/"><img src="<$MTBlogURL$>macromedia2/wandering-wind.gif" alt="Powered by Wandering Wind" width="104" height="32" border="0" /></a>
<br />
Copyright : [Articles] (C) <$MTBlogName encode_html="1"$> All Rights Reserved.<br />
[Comments/Trackbacks] ... Authors of those have rights.
</div>
</div>
<!--end pagecell1-->
<br />
</body>
</html>

4.タグへのリンクを作成する

タグを各記事に表示していますので、そこから自サイトの記事で同じタグを使ってる記事を探せるようにします。
また、Technoratiのタグ検索機能がありますので、これを利用してTechnoratiで検索するボタンも追加します。

尚、ここで使用している「Technoratiで検索ボタン」は私がテキトーに作成したものなので、もし利用したいという奇特な方がいらっしゃいましたらご自由にご利用いただいて結構です。この記事宛にコメントかトラックバックでもいただければ非常に嬉しいです。

コレ→Technoratiで検索アイコン

各記事にはこんなタグを追加しています。

<div id="tags">
<dl class="meta">
<dt>Tag:</dt>
<MTEntryTags>
<dd>
<a href="<$MTBlogURL$>tag/<$MTTag encode_url="1"$>"><$MTTag$></a><a href="http://www.technorati.com/tag/<$MTTag$>" rel="TAG" title="TAG:<$MTTag encode_url="1"$>"><img src="<$MTBlogURL$>images/techno.png" width="16" height="12" style="border: none;"
alt="Technoratiで検索" title="Technoratiで検索" /></a>,&nbsp;
</dd>
</MTEntryTags>
</dl>
</div>

スタイルシートにはこんな感じで書いてやれば良いのかな?
まぁこの辺はお好きにどうぞ。

#tags{
    border: 1px solid #cccccc;
    margin:2px 3px 2px 3px;
}

#tags .meta dt, #tags .meta dd {
    display: inline;
    list-style-type: none;
    margin: 0;
    padding: 0 1px;
}

タグ付けは最初は面倒ですが、記事の関連性を後から探すことが出来たりと非常に便利です。
どうぞ一度おためしアレ。

Posted by IGALOG at 2006年01月08日 07:06 | コメント (0) | トラックバック (0) |
My Clip!! | はてなブックマークに追加 | del.icio.usに追加

この記事に関連するかもしらんモノ

この記事に対するコメント

この記事に対するコメントはまだありません。


www.flickr.com

コメントを投稿する




保存しますか?

(書式を変更するような一部のHTMLタグを使うことができます)


この記事のトラックバックURL


この記事に対するトラックバック

この記事に対するトラックバックはまだありません。



Made with dreamweaverMade with fireworksPowered by Movable Type 3.2-ja-2Powered by Wandering Wind アクセスランキング
Copyright : [Articles] (C) IGALOG-R All Rights Reserved.
[Comments/Trackbacks] ... Authors of those have rights.