Untitled

mail@pastecode.io avatar
unknown
php
2 years ago
684 B
2
Indexable
Never
function smarty_block_foreach_page_item($params, $content, &$smarty, &$repeat){
	static $page,$count;
	if(!$params['perpage'])
		$smarty->trigger_error('foreach_page: missing <perpage> tag');
	if(is_null($content)){
		$page=$params['page']?$params['page']:1;
		$count=0;
	} else
		$count++;
	reset($params['from']);
	for($i=0;$i<($page-1)*$params['perpage']+$count;$i++)
		each($params['from']);
	if($count<$params['perpage']&&$item=each($params['from'])){
		$repeat=true;
		if($params['key'])
			$smarty->assign($params['key'],$item['key']);
		if($params['item'])
			$smarty->assign($params['item'],$item['value']);
	} else
		$repeat=false;
	return $content;
}