Welcome Guest, Not a member yet? Register   Sign In
uri segment vs form GET uri into same controller...?

Say I am looking at page 3 of some result set.
So the next/prev page links are :


In the page navigation bar, I have a "jump to page" field.
Suppose the user types in 87 and clicks the jump button.

This will generate a GET request something like:


But what I need now is


I can invent solutions, but this must be a common/easy problem
(he says hopefully).

How does a controller distinguish between these two equivalent entry points?
Noob here. Which part of the manual do I need to re-read?

You could do this:
1. Change your form action to post
2. Send it to a controller like video/go
3. Fetch the post value and redirect

This would be in controller video/go:
function go()
    // Fetch the page number from post
    // Typecast jump_to_page as an absolute integer first
    $page_id = abs((int) $this->validation->jump_to_page);
    // Redirect the user to the right page
    redirect('video/browse/page/' . $page_id, 'refresh');

Don't forget to set a validation rule for your jump_to_page field: trim|numeric

For a better user experience, you could calculate the number of pages and add a jQuery auto completion script to the jump_to_page field in video/browse. (or change the field to a dropdown with valid page numbers)

Perfect thank you.

The input class is where I need to look.

POST works great in this case.
From the manual somewhere: "CI does not do GET".
I will have to wrap my head around that.

Theme © iAndrew 2016 - Forum software by © MyBB