duanmei2805 2011-04-29 22:27
浏览 18
已采纳

Kohana 3 Pagination&Route问题

This is a bit cryptic, especially on day 1. Could use some help if you dont mind. Controller is search, on action_query($search_term)

So right now its /search/query/some query?page=1 (this is without a route) Need to get it setup in this format..

/search/some query/1
1 being the page with pagination

        $pagination = Pagination::factory(array(
            'current_page'      => array('source' => 'route', 'key' => 'page'),
            'total_items'       => $count,
            'items_per_page'    => 100,
            'view'              => 'pagination/basic',  
        ));

With Route

 Route::set('page', '<controller>/<action>/<search_term>(/<page>)')
    ->defaults(array(
        'action' => 'query',
        'search_term' => '[a-zA-Z0-9 ]',
        'controller' => 'search',
        'action' => 'page',
        'page' => '1',
    )
);
  • 写回答

1条回答 默认 最新

  • douzhaxian1267 2011-04-29 22:48
    关注

    I have a pagination working and my route looks like:

    Route::set('comments', 'welcome/index(/<page>)', array('page' => '[0-9]+'))
    ->defaults(array(
        'controller' => 'welcome',
        'action'     => 'index'
    ));
    

    Also, I think you are missing a parameter when creating the paginator, which is:

    'uri_segment'    => 'page', // pass a string as uri_segment to trigger former 'label' functionality.
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?