问题
I have the following issue:
When I press a button in my pagination, CLinkPager generates the link as follows:
page/videos/445/?page=2
What I need is something like this:
page/videos/445/page/2
Furthermore, I need something like:
name/videos/2
where name is url of user_id = 445.
I've set some rules in urlManager but they don't quite do the job: For step 1:
'<controller:\w+>/<action:\w+>/<id:\d+>/<page:\d+>' => '<controller>/<action>',
Any help is appreciated. Thank you in advance!
回答1:
Here example for page/videos/445/page/2.This will help you understand:
//config
'rules'=>array(
'page/videos/<number:\d+>/page/<pageId:\d+>' => '/site/test',
...
//...SiteController...
//url for call www.your_site.lh/page/videos/445/page/2
public function actionTest($number, $pageId)
{
echo '<pre>';
print_r($_GET);
echo "$number<br/>";
echo "$pageId<br/>";
echo '</pre>';
die();
}
URL Management
If you want to change generation links in pager you can override CLinkPager.
来源:https://stackoverflow.com/questions/30483938/yii-clinkpager-urlmanager-rules