Smartyでforを回してページャーのようなものを作るには

nesys Add comments
タグ: ,
add to hatena hatena.comment (1) add to del.icio.us (1) add to livedoor.clip (0) add to Yahoo!Bookmark (0) Total: 2

Smartyのsection関数のiterationを使うことでループの現在の値を得られるので、それを活用しよう。
実際に見た方が圧倒的に早いだろう。

{section name=pager loop=$allpagenum}
	{if $curpage == $smarty.section.pager.iteration}
		<strong>{$smarty.section.pager.iteration}</strong>
	{else}
		<a href="リンク先&page={$smarty.section.pager.iteration}">{$smarty.section.pager.iteration}</a>
	{/if}
{/section}

$allpagenumにはページ数をsetしておく。
$curpageには現在のページをsetしておく。

まぁこういうこと。

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS ログイン