phpcakephppagination

How to customize CakePHP pagination url?


currently i am using cakephp version 2.5.3

I want to change my cakephp pagination url.

My current URL is http://www.example.com/newsFeeds/ajax_news_feed/page:2 I need http://www.example.com/newsFeeds/index/page:2

My Code:

<?php
    echo $this->Paginator->prev(' <<' . __('Previous  '), array(), null, array('class' => 'prev disabled'));
    echo $this->Paginator->numbers();
    //echo $this->Paginator->url(array('controller'=>'newsFeeds', 'action'=>'index'));
    //echo $this->Paginator->link('Sort by title on page 5', array('controller'=>'newsFeeds', 'action'=>'index'));
    echo $this->Paginator->next(__('  Next') . '>> ', array(), null, array('class' => 'next disabled'));
?>

Above pagination is showing-

tt

When i am clicking 2 then the link is going to http://www.example.com/newsFeeds/ajax_news_feed/my_post/page:2 but i need http://www.example.com/newsFeeds/index/my_post/page:2

Please tell me how to change controller and action in pagination?


Solution

  • User $this->Paginator->options-

    Code:

    <?php
        $this->Paginator->options['url'] = array('controller' => 'newsFeeds', 'action' => 'index/my_post');
        echo $this->Paginator->prev(' <<' . __('Previous  '), array(), null, array('class' => 'prev disabled'));
        echo $this->Paginator->numbers();
        echo $this->Paginator->next(__('  Next') . '>> ', array(), null, array('class' => 'next disabled'));
    ?>