Php 调用分页控件帮助程序时,如何使用参数设置路由?
我正在尝试在新闻页和具有指定类别的新闻页上添加分页控件 对于简单新闻提要和具有指定新闻的新闻提要(Php 调用分页控件帮助程序时,如何使用参数设置路由?,php,routing,pagination,zend-framework2,Php,Routing,Pagination,Zend Framework2,我正在尝试在新闻页和具有指定类别的新闻页上添加分页控件 对于简单新闻提要和具有指定新闻的新闻提要(news和news/category),我有两种不同的路径和操作。我想在页面中添加分页控件。我发现,我需要这样做(在简单的新闻提要中,它是有效的): 你的方法似乎是正确的。你能将新闻/类别路由配置添加到问题中吗?@foozy我用路由配置更新了我的问题。 <?=$this->paginationControl( $this->news, 'Sliding',
news
和news/category
),我有两种不同的路径和操作。我想在页面中添加分页控件。我发现,我需要这样做(在简单的新闻提要中,它是有效的):
你的方法似乎是正确的。你能将新闻/类别路由配置添加到问题中吗?@foozy我用路由配置更新了我的问题。
<?=$this->paginationControl(
$this->news,
'Sliding',
'pagination_control',
array('route' => 'news/pagination')
)?>
<?=$this->paginationControl(
$this->news,
'Sliding',
'pagination_control',
array('route' => 'news/category/pagination', array('category' => $this->category->getUrl()))
)?>
'news' => array(
'type' => 'Segment',
'options' => array(
'route' => '/news',
'defaults' => array(
'controller' => 'News\Controller\Item',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
// other news child routes,
'category' => array(
'type' => 'Segment',
'options' => array(
'route' => '/:category',
'constraints' => array(
'category' => '[a-z]+',
),
'defaults' => array(
'controller' => 'News\Controller\Item',
'action' => 'category',
)
),
'may_terminate' => true,
'child_routes' => array(
'pagination' => array(
'type' => 'Segment',
'options' => array(
'route' => '/page-:page',
'constraints' => array(
'page' => '[1-9][0-9]*',
),
'defaults' => array(
'page' => 1,
)
),
'may_terminate' => true,
),
),
),
),
),