Welcome Guest, Not a member yet? Register   Sign In
Third segment of URI
#1

[eluser]juan1904[/eluser]
Hi,

I'm working on a forum for my webpage which got a pagination function, and it works perfectly fine when I'm browsing the first page of the forum, but when I click my pagination to view the second page I get a "404 Page Not Found"-error.
Here's some code from my controller:
Code:
function index($offset = 0)
    {
        $this->load->library('pagination');

        // Some code for my pagination
        $data['pagination'] = $this->pagination->create_links();

        // Get all threads from database.
        $data['threads'] = $this->db->get('forum_threads', 15, $offset)->result_array();

        // Loading the view.
        $data['content'] = 'forum/threads';
        $this->load->vars($data);
    }

The URI seem to not like that I give my index-function a parameter.
I've got a .htaccess file which removes index.php from my URI.
#2

[eluser]juan1904[/eluser]
I found my problem now. I need to write the URI like forum/index/(a number). But I don't want to write the second URI index, is there any way to write it like forum/(a number)
#3

[eluser]Dam1an[/eluser]
URI routing to the rescue
#4

[eluser]juan1904[/eluser]
I've actually already read that one ;-)

But I don't understand how I can get 2 URI-segments when the real URI is 3 segments.
#5

[eluser]Dam1an[/eluser]
Well, if you want forum/123 to point to forum/index/123, use something like
Code:
$route['forum/(:num)'] = 'forum/index/$1';

Make sense?
#6

[eluser]juan1904[/eluser]
Thank you Dam1an!
#7

[eluser]Dam1an[/eluser]
You're welcome
(Damian does it again!) Wink




Theme © iAndrew 2016 - Forum software by © MyBB