Yii Framework Forum: Urlmanager + Cpagination - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Urlmanager + Cpagination Rate Topic: -----

#1 User is offline   ifelse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 21-February 13

Posted 21 February 2013 - 06:04 PM

I've created module, that action show list of models with pagination: example.com/article/default/index?page=X
I want write rule, which it's looks like: example.com/article/X

My config:
        'urlManager' => array(
            'urlFormat' => 'path',
            'showScriptName' => false,
            'rules' => array(
                ...
                'article/<page:\d+>' => 'article/default/index',
            ),
        ),

Links in paginator genereted rigtht, but if I click in link I have 404 error.

P.S.: sry for my english <_<
Sorry for my English ;)
0

#2 User is offline   Maciej Liżewski 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 862
  • Joined: 02-July 10
  • Location:Central Poland

Posted 22 February 2013 - 06:32 AM

a nd what is '...' stand for? maybe there is another rule that matches url-s like '/article/2' and because it is earlier on the list - it wins and is used to handle request?
red
0

#3 User is offline   ifelse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 21-February 13

Posted 22 February 2013 - 07:43 AM

other rules:
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',

Sorry for my English ;)
0

#4 User is offline   Maciej Liżewski 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 862
  • Joined: 02-July 10
  • Location:Central Poland

Posted 22 February 2013 - 07:57 AM

 '<controller:\w+>/<id:\d+>' => '<controller>/view',

this one matches your requests and causes 404.

try this order:
'article/<page:\d+>' => 'article/default/index',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',

red
0

#5 User is offline   ifelse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 21-February 13

Posted 22 February 2013 - 07:55 PM

Thank you. Problem solved :)
Sorry for my English ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users