Welcome Guest, Not a member yet? Register   Sign In
Pagination with URI segment

(This post was last modified: 08-14-2022, 03:36 AM by mohs3n.)

Hello all
I am writing a simple blog application and want to have a pagination like the following: https://sampleblog.local/posts/page/2
Default pagination is like: https://sampleblog.local/posts?page=2

I have read the documentation : https://codeigniter4.github.io/CodeIgnit...t-for-page
But still cannot implement it.
I would appreciate it if anyone can provide a sample code.

My controller:
PHP Code:
        $data['articles'] = $posts->orderBy('id','DESC')
                            ->where("type = 'article' AND status = 'publish'")
        $data['pager'] = $posts->pager

$model->paginate(5, 'default', null, 3);
Set last parameter as segment number (test 2 or 3)

Theme © iAndrew 2016 - Forum software by © MyBB