Search code examples
phppaginationyii1.x

Yii 1 Pagination showing different behaviour in different controllers


In my Yii application, some controllers returning pagination URL as follows:

http://example.com/blog/index?page=2

And if I have written the same code in some other controller, then the pagination URL shows as follows:

http://example.com/blog/index/page/2

Any idea why it showing differently in different controllers? I need the page number as a query string (like the first URL).


Solution

  • Finally I got the issue, I have missed the following rule in my route file, which caused the issue.

    '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
    

    This should be added as follows:

    return array(
        ......
        'components'=>array(
            ......
            'urlManager'=>array(
                'urlFormat'=>'path',
                'rules'=>array(               
                    '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                ),
            ),
        ),
    );