TOP > 技術系 > smarty >

smartyでページング

このエントリーをはてなブックマークに追加

smartyでのページング処理。PHPのほうで処理したほうが簡単な気もするけど。

assinしておくのは

$SA['row'] 総項目数
$SA['max_page'] 総ページ数
$SA['pager'] 1ページの表示件数

{section name=cnt loop=$SA.max_page}
	{if $smarty.section.cnt.first and $smarty.get.page!=1}
	<a href='?page={$smarty.get.page-1}'>←前の{$SA.pager}件へ</a>
	{/if}
	{if $smarty.section.cnt.iteration==$smarty.get.page}
	<em>{$smarty.section.cnt.iteration}</em>
	{else}
	<a href="?page={$smarty.section.cnt.iteration}">{$smarty.section.cnt.iteration}</a>
	{/if}
	{if $smarty.section.cnt.last and $smarty.get.page!=$smarty.section.cnt.iteration}
	<a href='?page={$smarty.get.page+1}'>→次の{if $SA.pager*$smarty.get.page.page<$SA.row}{$SA.pager}{else}{$SA.row-$SA.pager*$smarty.get.page}{/if}件へ</a>
	{/if}
{/section}

sectionをfor文ぽく利用するのがポイント。

ceil関数に対応しているんだったらmax_pageとかもassinせずに取得できるのにな

スポンサードリンク

smartyに関するエントリー

カテゴリ:

トラックバック(0)

このブログ記事を参照しているブログ一覧: smartyでページング

このブログ記事に対するトラックバックURL: http://www.kazumanishihata.com/mt/mt-tb.cgi/250

コメントする

関連エントリー

スポンサードリンク

グルメ

  • 鶴丸のカレーうどん
  • めりけんや[うどん][高松]
  • 凱陣
  • 北古馬場 ごえもんのカレーうどんで〆 [高松]
  • かき揚げ
  • うどん
  • みのりんご[原宿][カレー][ランチ]
  • 第2回ご当地パン祭りで優勝したクロワッサンB.C
  • テール
  • 〆は冷やし讃岐

よく食べに行く場所

このブログ記事について

このページは、西畑一馬が2008年7月 1日 17:36に書いたブログ記事です。

ひとつ前のブログ記事は「怒涛の6月終了」です。

次のブログ記事は「Google AdSense紹介ユニット終了」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。