![]() |
How do I use Codeigniter pagination inside Twig views? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: How do I use Codeigniter pagination inside Twig views? (/showthread.php?tid=78046) |
How do I use Codeigniter pagination inside Twig views? - Ajax30 - 11-24-2020 I am working on a online newspaper/blogging application with CodeIgniter 3.1.8 and Bootstrap 4. I have decided to add themes to it. The application is not HMVC, only MVC. I thought it was a good idea to use the Twig template engine to the theme(s). For this purpose, I use CodeIgniter Simple and Secure Twig. The public views have the extension .twig, not .php. This part of the Posts controller is responsible with displaying the posts with pagination: PHP Code: private function _initPagination($path, $totalRows, $query_string_segment = 'page') { If I had classic codeigniter views, I would display the pagination on page this way (I already did, in a previous version of the project): PHP Code: <div class="pagination-container text-center"> But I now need a way to pass the pagination to Twig views. Adding the code above does not work, and I have not been able to find a viable alternative. RE: How do I use Codeigniter pagination inside Twig views? - sammyskills - 11-24-2020 You can simply add that function as part of the data array that will be sent to the view in your controller, like so: Code: $data['pagination'] = $this->pagination->create_links(); Then in your twig template, you echo the variable: Code: {{ pagination }} |