Undefined variable $ inside template pagination - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Undefined variable $ inside template pagination (/showthread.php?tid=88803) |
Undefined variable $ inside template pagination - rax - 11-09-2023 Hello all! after upgrading from 4.2.2 to 4.4.3 and php7.4 to 8.2 my pagination template started to fail, isn't get some vars from controller, perhaps I missed something during upgrade and a little help can solve this issue. Undefined variable $ ---------- config/pager.php - OK PHP Code: public array $templates = [ Controllers/Main.php - OK PHP Code: public function pagination(){ /Views/pages/list.php - OK PHP Code: $pager->makeLinks($page, $perPage, 'front_full') /Views/layouts/custom_pagination.php- OK but don't receive $page or $perPage vars... -> Undefined variable $page and $perPage Thank you for your support, RE: Undefined variable $ inside template pagination - kenjis - 11-09-2023 Now Pager does not use the shared View instance. See https://github.com/codeigniter4/CodeIgniter4/issues/7703 RE: Undefined variable $ inside template pagination - rax - 11-10-2023 (11-09-2023, 10:13 PM)kenjis Wrote: Now Pager does not use the shared View instance. Thanks for your answer, I didn't saw any related info regarding that under: https://www.codeigniter.com/user_guide/installation/upgrading.html or https://www.codeigniter.com/user_guide/libraries/pagination.html ... Does codeigniter4 provide that with some builtin function or we've to build it? Regards, RE: Undefined variable $ inside template pagination - kenjis - 11-10-2023 It is a bug fix. No detailed info is documented in the user guide. Why do you need these variables? Can you get needed info from the $pager object? RE: Undefined variable $ inside template pagination - rax - 11-10-2023 To display the number of records from tables in many pages without write the same code and html/css in every one. RE: Undefined variable $ inside template pagination - kenjis - 11-10-2023 Use the Pager object instead of variables to Views. https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/Pager/Pager.php RE: Undefined variable $ inside template pagination - xuanvu2911 - 01-04-2024 (11-09-2023, 12:01 PM)rax Wrote: Hello all!You can try: <php $pager_inf = \Config\Services::pager() $page = $pager_inf -> getCurrenPage(); $total = $pager_inf ->getTotal(); $perPage = $pager_inf->getPerPage(); ?> } ?> |