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

(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'")
                            ->paginate(5);
        $data['pager'] = $posts->pager
Reply
#2

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




Theme © iAndrew 2016 - Forum software by © MyBB