以下是智能插件的PHP代码,用于对页面应用分页。
<?php
function smarty_function_pagination_link_01($params, &$smarty)
{
if ( !is_array($params['values']) )
{
return "is not array";
}
if ( 0 == count($params['values']) )
{
return "Empty Array";
}
if ( empty($params['values']['current_page']) )
{
return "Invalid Request";
}
$values = $params['values'];
//Seperator Used Betwinn Pagination Links
$seprator = empty( $params['seperator'] ) ? " " : $params['seperator'];
//Class Name For Links
$extra = empty( $params['extra'] ) ? "" : $params['extra'];
$current_page = (int)$values['current_page'];
if ( !empty($values['first']) )
{
//$ret[] = "<a $extra href='{$values['first']}' ><First</a>";
}
if ( !empty($values['previous'] ) )
{
$ret[] = "<a $extra href='{$values['previous']}' class='prev active'><span></span></a>";
}
$ret[] = "<ul>";
foreach( $values as $k => $v )
{
if( is_numeric( $k ) )
{
if ( $k == $current_page)
{
$ret[] = "<li><a $extra class='active'>$k</a></li>";
}
else
{
$ret[] = "<li><a $extra href='$v'>$k </a></li>";
}
}
}
if ( !empty($values['next'] ) )
{
$ret[] = "</ul><a $extra href='{$values['next']}' class='next active'><span></span></a>";
}
if ( !empty($values['last'] ) )
{
//$ret[] = "<a $extra href='{$values['last']}' >Last></a>";
}
//$str_ret = $first . $previous . $str_ret . $next . $last;
if ( $ret )
{
return implode( $seprator, $ret );
}
}
?>
从smarty模板调用此函数。现在它完美无缺。但是我想改变上面函数的行为,我想改变它返回的值。上述函数获取的参数$params
的值如下:
Array
(
[values] => Array
(
[1] => /xyz/pqr/web/control/modules/questions/view_questions.php?subject_id=&topic_id=&difficulty_level=&from_date=01/02/1999&to_date=17/02/2014&staff_id=&page=1
[2] => /xyz/pqr/web/control/modules/questions/view_questions.php?subject_id=&topic_id=&difficulty_level=&from_date=01/02/1999&to_date=17/02/2014&staff_id=&page=2
[3] => /xyz/pqr/web/control/modules/questions/view_questions.php?subject_id=&topic_id=&difficulty_level=&from_date=01/02/1999&to_date=17/02/2014&staff_id=&page=3
[next] => /xyz/pqr/web/control/modules/questions/view_questions.php?subject_id=&topic_id=&difficulty_level=&from_date=01/02/1999&to_date=17/02/2014&staff_id=&page=2
[last] => /xyz/pqr/web/control/modules/questions/view_questions.php?subject_id=&topic_id=&difficulty_level=&from_date=01/02/1999&to_date=17/02/2014&staff_id=&page=8170
[current_page] => 1
)
)
现在页码的显示如下: ![在此输入图像说明] [1]
但我希望以下列方式使用分页数字:
1 2 3 4 5 6 7 8 9 10 Next Last
如何通过更改功能来获得上述模式?提前感谢。
答案 0 :(得分:0)
尝试使用num_links
$config['num_links'] = 10;