我有 4 条通往同一控制器/动作的路线。
Router::connect('/noticias/:id/:slug/*', array(
'controller' => 'posts', 'action' => 'listing', 'admin' => false),
array(
'pass' => array('id','slug'),
'id' => '[0-9]+',
'slug' => '[a-zA-Z0-9_-]+'
)
);
Router::connect('/servicos/:id/:slug/*', array(
'controller' => 'posts', 'action' => 'listing', 'admin' => false),
array(
'pass' => array('id','slug'),
'id' => '[0-9]+',
'slug' => '[a-zA-Z0-9_-]+'
)
);
Router::connect('/aplicacoes/:id/:slug/*', array(
'controller' => 'posts', 'action' => 'listing', 'admin' => false),
array(
'pass' => array('id','slug'),
'id' => '[0-9]+',
'slug' => '[a-zA-Z0-9_-]+'
)
);
Router::connect('/produtos/:id/:slug/*', array(
'controller' => 'posts', 'action' => 'listing', 'admin' => false),
array(
'pass' => array('id','slug'),
'id' => '[0-9]+',
'slug' => '[a-zA-Z0-9_-]+'
)
);
但是,当我尝试为这些不同的路由生成分页时,CakePHP 只会为 routes.php 文件中的第一个(找到的)路由生成。
我怎样才能得到具体的路线?还是在 Paginator 中手动设置路由?
什么是最好的解决方案?创建 4 个动作?正则表达式?重定向?
<div class="paging right">
<?php $this->Paginator->options(array(
'url'=> array(
'controller' => 'posts',
'action' => 'listing',
'id' => $this->params->pass['0'],
'slug' => $this->params->pass['1'],
'admin' => false
)
)); ?>
<?php echo $this->Paginator->prev('<' . __(''), array(), null, array('tag' => 'a', 'separator' => '')); ?>
<?php echo $this->Paginator->numbers(array('separator' => '')); ?>
<?php echo $this->Paginator->next(__('') . '>', array(), null, array('tag' => 'a', 'separator' => '')); ?>
</div>