Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Pagination Routing
  • I noticed the following comment on a question about pagination links giving a 404, which is an issue I'm experiencing:

    "Are your routes setup to accept the additional URI segments?"

    However I can't see any info in the Pagination docs about how the routes need to be set up.

    My configuration is as follows:

    $config = array(
    'pagination_url' => \Uri::create('product'),
    'total_items' => Model_Product::count(),
    'per_page' => 2,
    'uri_segment' => 2,
    'template' => 'bootstrap',
    );

    $pagination = Pagination::forge('mypagination', $config);
    $data['pagination'] = $pagination->render();

    ...get $data['items'] etc...

    I think it should be something like:

    'product(/:num)' => array('product/$1'),

    in routes.php, but that doesn't seem to be it.

    Any advice appreciated,

    Paul

  • Actually:

    'product/:page' => 'product',

    in routes.php seems to work. Is this the de facto method?
  • HarroHarro
    Accepted Answer
    Normally you shouldn't need any routes, as the default for the URI is: controller/method/any/params/you/want/to/pass.

    You do need a route if you want the page number to be the second URI segment, which by default is reserved for the action method name.

    Which route you need depends on how you created the controller. If your action_index deals with pagination, you can route to 'product/index' or 'product' (which defaults to 'index'), both work fine.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion