ページ

100820

1. 【mtのめも】

PageBute プラグインで生成されるページの各記事の見出しに
別ページで表示している 記事リストからリンクする

●一覧ページ
/index.html

●PageBute で5件ずつ表示されるページ 1ページ目
/news/index.html


●PageBute で5件ずつ表示されるページ 2ページ目
/news/index_2.html

「一覧ページ」のテキストリンクをクリックしたら 5件ずつ表示されるページの見出しに飛ぶようにする

例えば
「一覧ページ」の「新着情報その2」をクリックしたら 1ページ目の「新着情報その2」へ
「一覧ページ」の「新着情報その1」をクリックしたら 2ページ目の「新着情報その1」へ


htmlの記述
●一覧ページ /index.html
<a href="/news/index.html#entry-6">新着情報6</a>
<a href="/news/index.html#entry-5">新着情報5</a>
<a href="/news/index.html#entry-4">新着情報4</a>
<a href="/news/index.html#entry-3">新着情報3</a>
<a href="/news/index.html#entry-2">新着情報その2</a>
<a href="/news/index_2.html#entry-1">新着情報その1</a>

●1ページ目 /news/index.html
<h2 id="entry-6">新着情報6</h2>

<h2 id="entry-5">新着情報5</h2>

<h2 id="entry-4">新着情報4</h2>

<h2 id="entry-3">新着情報3</h2>

<h2 id="entry-2">新着情報その2</h2>


●2ページ目 /news/index_2.html
<h2 id="entry-6">新着情報6</h2>

これを MTテンプレートから生成すればいい

MTテンプレートの記述
●一覧ページ
<mt:setvar name="entry_count" value="0" />

<mt:entries>

  <mt:setvarblock name="page_count"><mt:var name="entry_count" op="/" value="5" sprintf="%d" /></mt:setvarblock>

  <a href="/news/index<mt:unless name="page_count" eq="0">_<mt:var name="page_count" op="++" />.html</mt:unless>#entry-<mt:entryid />"><mt:entrytitle /></a>

  <mt:setvar name="entry_count" op="++" />

</mt:entries>

●1ページ目 2ページ目 3… 
<MTPageContents count="5">
  <mt:entries>
    <h2 id="entry-<mt:entryid />"><mt:entrytitle /></h2>
    <mt:entrybody />
    <$MTPageSeparator$>
  </mt:entries>
</MTPageContents>

<ul class="pagelist">
  <MTIfPageBefore>
    <$MTPageBefore delim="<"$>
  </MTIfPageBefore>
  <$MTPageLists delim=" " link_start="<li>" link_close="</li>"$>
  <MTIfPageNext>
    <$MTPageNext delim=">"$>
  </MTIfPageNext>
</ul>



参考記事
http://bit.ly/9We9zN sprintfモディファイアをつかって整数をとりだす
http://bit.ly/bGgtMw PageButeプラグインの紹介

0 件のコメント: