Php寻呼机问题

时间:2009-12-24 13:56:40

标签: php pager

我正在PHP中使用寻呼机类(来自pear)。我不确定我是否正确使用它,但我从Internet下载了一些代码,我可以在其中包含一个寻呼机类并调用寻呼机功能.. 这就是我在php页面中调用Pager函数的方法......

require_once('pager/Pager.php');
 $pager_options = array(
        'mode'       => 'Sliding',
        'append'    => false,
        'perPage'    => 30,
        'delta'      => 4,
        'fileName'  => '/temp-%d.htm',
        'currentPage' => $pagenum,        
        'totalItems' => $rows,
        'curPageLinkClassName' => 'active',
        'separator' => '',
        'nextImg' => '<strong>Next</strong> &raquo;',
        'prevImg' => '&laquo; <strong>Previous</strong>',
        'spacesBeforeSeparator' => 0,
        'spacesAfterSeparator' => 0,
        'clearIfVoid' => true
        );
        $pager = Pager::factory($pager_options);
        echo '<div align="center" id="pagination">' .  $pager->links . '</div>';

现在,它工作正常,但我的问题是,对于第一页,链接将是temp-1.htm,但我想要它作为temp.htm或temp / index.htm ...对于其他页面,temp -2.htm,temp-3.htm很好..

有什么工作吗?提前谢谢......

2 个答案:

答案 0 :(得分:0)

echo '<div align="center" id="pagination">',
     str_replace('temp-1.htm', 'temp.htm', (string) $pager->links),
     '</div>';

答案 1 :(得分:0)

对Pager不是很熟悉,但是你可以有类似的东西

require_once('pager/Pager.php');

 $filename = ($pagenum == 1) ? 'temp.htm' : '/temp-%d.htm';

 $pager_options = array(
        'mode'       => 'Sliding',
        'append'    => false,
        'perPage'    => 30,
        'delta'      => 4,
        'fileName'  => $filename,
        'currentPage' => $pagenum,        
        'totalItems' => $rows,
        'curPageLinkClassName' => 'active',
        'separator' => '',
        'nextImg' => '<strong>Next</strong> &raquo;',
        'prevImg' => '&laquo; <strong>Previous</strong>',
        'spacesBeforeSeparator' => 0,
        'spacesAfterSeparator' => 0,
        'clearIfVoid' => true
        );
        $pager = Pager::factory($pager_options);
        echo '<div align="center" id="pagination">' .  $pager->links . '</div>';