Welcome Guest, Not a member yet? Register   Sign In
How to use the pagination with view parser?
#1

Hello there!
I am building a view with pagination with view parser, the problem is how I spend the value of pager to build my links? since it is an object and in view parser it is not possible to use them
Code:
$data = [
    'rows' => $this->model->paginate(2),
    'pager' => $this->model->pager
];
grettings!
Reply
#2

At the bottom of the UG page (https://codeigniter4.github.io/userguide...ation.html), a pagination objet will have `links()` that you can inject into your view at the proper place.

I thought there was something inside the Model class as well, but it isn't jumping out at me.
Reply
#3

Not having idea how to do it... If you find the solution please tell me too.
No SEO spam - see forum guidelines
Reply
#4

(This post was last modified: 07-02-2021, 06:24 AM by eternity6. Edit Reason: beautiful formatting )

Well...You can simple put HTML result of pager inside an array with a specific label in your control and then parser it with a {  code } in the template.

For example

Controller:

PHP Code:
$this->data['page_pagination'] = $data['pager']->links();

//than call view template
//i have write a library for parser a page splitted in multiple file
echo $this->TemplateParser->_render_page('your_template_to_parser'$this->datatruefalse);

//if you don't like use original C4 
echo $this->parser->setData($data)->render('your_view_file'); 



In your template view use code with ! for don't print HTML code

Code:
<div class="pagination">{! page_pagination !}</div>
Reply




Theme © iAndrew 2016 - Forum software by © MyBB