Movable Type(MT)にて現在のカテゴリ(フォルダ)から最上位のカテゴリ(フォルダ)まで繰り返し表示。
パンくずリストで利用する際など、最上位のカテゴリ(フォルダ)から現在のカテゴリ(フォルダ)を繰り返す場合は、以下のようにどちらかでできます。
カテゴリ:<mt:ParentCategories glue=">"><$mt:CategoryLabel$></mt:ParentCategories>
フォルダ:<mt:ParentFolders><$mt:FolderLabel$></mt:ParentFolders>
head内のtitleタグに利用するときは、現在のカテゴリ(フォルダ)から最上位のカテゴリ(フォルダ)まで繰り返し表示した方がサイトっぽくなります。
以下が流れになります。
・配列、カウンターを初期化
・最上位のカテゴリ(フォルダ)から現在のカテゴリ(フォルダ)を繰り返し
・カテゴリ名(フォルダ名)を配列にセット
・配列を逆順に表示
■カテゴリの場合
<mt:SetVar name="set_categorytitle" value="0">
<mt:SetVar name="counter" value="0">
<mt:ParentCategories>
<mt:SetVarBlock name="set_categorytitle[$counter]"><$mt:CategoryLabel$>|</mt:SetVarBlock>
<mt:SetVar name="counter" value="1"op="inc">
</mt:ParentCategories>
<mt:Loop name="set_categorytitle" sort_by="value numeric reverse"><mt:Var name="__value__"></mt:Loop>
実際の実行結果
※この記事の場合、最上位が「サイト制作」、現在が「Movable Type」なので逆順に表示されていればOK!
Movable Type|サイト制作|
■フォルダの場合
<mt:SetVar name="set_foldertitle" value="0">
<mt:SetVar name="counter" value="0">
<mt:ParentFolder>
<mt:SetVarBlock name="set_foldertitle[$counter]"><$mt:FolderLabel$>|</mt:SetVarBlock>
<mt:SetVar name="counter" value="1"op="inc">
</mt:ParentFolder>
<mt:Loop name="set_foldertitle" sort_by="value numeric reverse"><mt:Var name="__value__"></mt:Loop>
Pretty element of content. I simply stumbled upon your web site and in accession capital to say that I acquire actually enjoyed account your weblog posts.
Anyway I'll be subscribing for your feeds and even I success you access persistently rapidly.