1. ホーム
  2. ブログ
  3. Movable Type
  4. ウェブサイト配下すべてのブログから行った検索をウェブサイトの検索結果テンプレートで表示する
2009年12月17日

ウェブサイト配下すべてのブログから行った検索をウェブサイトの検索結果テンプレートで表示する

Movable Type 5で、ウェブサイトを「配下のブログ」のポータルとする場合、検索はすべてのブログにまたがった検索結果をウェブサイトの検索結果テンプレートで表示したい。

デフォルトのパラメータ

<input type="hidden" name="IncludeBlogs" value="<$mt:BlogID$>" />

パラメータにウェブサイト配下すべてのブログIDを渡す

<input type="hidden" name="IncludeBlogs" value="<$mt:WebsiteID$><mt:WebsiteHasBlog><mt:Blogs include_blogs="site">,<$mt:BlogID$></mt:Blogs></mt:WebsiteHasBlog>" />

この内容を使用してウェブサイトに検索モジュール(ウィジェットでも可)を作成

<form method="get" action="<$mt:CGIPath$><$mt:SearchScript$>">
<input type="hidden" name="IncludeBlogs" value="<$mt:WebsiteID$><mt:WebsiteHasBlog><mt:Blogs include_blogs="site">,<mt:BlogID></mt:Blogs></mt:WebsiteHasBlog>" />
<input type="hidden" name="limit" value="<$mt:SearchMaxResults$>" />
<label for="search">このサイトの検索</label>
<input type="text" size="15" id="search" name="search" value="<$mt:SearchString$>" />
<input type="submit" value="Search" />
</form>

ウェブサイト配下のブログからウェブサイトの検索モジュールをインクルードする

<mt:BlogParentWebsite>
<mt:SetVarBlock name="website_id"><mt:WebsiteID></mt:SetVarBlock>
<mt:Include module="検索" blog_id="$website_id"$>
</mt:BlogParentWebsite>

注意:ウィジェットで作成した場合はmoduleの部分をwidgetに変更すること

Posted
@Style
コメント (0)
トラックバック (0)

トラックバック

トラックバックURL
http://atstyle.biz/mt/t-back.cgi/1001

コメント

コメントを投稿

コメントは即時公開されません。確認後に公開しますので少しお待ちください。