特定のフォルダをフィルタリング

MTWriteToFileプラグインでフォルダアーカイブという記事を書きましたが、フォルダアーカイブを作りたくないフォルダもあります。

そこで、WingMemo: 特定のフォルダを表示・非表示にするの記事をもとに、

<mt:SetVarBlock name="folname"><$mt:FolderLabel$></mt:SetVarBlock>
<mt:Unless name="folname" like="表示したくないフォルダA|表示したくないフォルダB">
ここに内容
</mt:Unless>

とします。

実際のテンプレートは次のようになります。この場合は、エラーフォルダアーカイブが出力されません。

<mt:TopLevelFolders>
<mt:SetVarBlock name="foldername"><$mt:FolderLabel$></mt:SetVarBlock>
<mt:Unless name="foldername" like="エラー">
<mt:SetVarBlock name="fname"><mt:FolderPath>/index.html</mt:SetVarBlock>
<mt:WriteToFile file="$fname"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
<head>
<$mt:Include module="HTMLヘッダー"$>
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="<$mt:Link template="rsd"$>" />
<title><$mt:FolderLabel$> - <$mt:BlogName encode_html="1"$></title>
<script type="text/javascript" src="http://<$mt:BlogHost$>/prototype.js"></script>
<script type="text/javascript" src="http://<$mt:BlogHost$>/ajaxUtil.js"></script>
<mt:SetVar name="folder_archive" value="1">
</head>
<body id="<$mt:BlogTemplateSetID$>" class="mt-main-index <$mt:Var name="page_layout"$>">
<div id="my_body">
<$mt:Include module="バナーヘッダー"$>
<div id="content">
<div id="my_contents">
<h2 id="top"><$mt:FolderLabel$></h2>
<mt:Pages lastn="10">
<div class="contents_box" id="entry-<$mt:PageID$>">
<h3><a href="<$mt:PagePermalink$>" title="<$mt:PageTitle encode_html="1"$>に移動します"><$mt:PageTitle encode_html="1"$></a></h3>
<div class="contents_comment">
<div class="asset-body">
<$mt:PageBody$>
</div>
<mt:If tag="PageMore">
<p class="read_more"><a href="<$mt:PagePermalink$>#more" title="<$mt:PageTitle encode_html="1"$>の続きに移動します">続きを読む</a></p>
</mt:If>
</div>
</div>
<p class="to_top" title="このページの先頭に戻ります"><a href="#my_body">ページ先頭に戻る</a></p>
</mt:Pages>
</div>
<$mt:Include module="サイドバー"$>
</div>
<$mt:Include module="バナーフッター"$>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-1162389-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html></mt:WriteToFile>
<mt:SubFolderRecurse>
</mt:Unless>
</mt:TopLevelFolders>

としました。

関連エントリー