![]() |
CI4 beta.1 - How to load view in view with layout - 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: CI4 beta.1 - How to load view in view with layout (/showthread.php?tid=72992) |
CI4 beta.1 - How to load view in view with layout - pinebranch - 03-08-2019 Hello, In beta 1, how can I load a partial view in a view with layout? When I use this code, nothing is rendered. PHP Code: <?= $this->extend('layout') ?> But without layout, it will work. PHP Code: <?= view('partial'); ?> RE: CI4 beta.1 - How to load view in view with layout - elephpantech - 03-08-2019 (03-08-2019, 01:40 AM)pinebranch Wrote: Hello, His error report seems to be similar to that found by me: https://forum.codeigniter.com/thread-72967.html RE: CI4 beta.1 - How to load view in view with layout - pinebranch - 03-10-2019 I solved this by extending the core View class, added a function to render partial view. Function renderPartial is combined from function render and renderString of the View class. I also put additional data for partial view in $options parameter. PHP Code: <?php namespace App\Core; In app\Config\Services.php, add a function to override renderer service using MyView PHP Code: public static function renderer($viewPath = null, $config = null, bool $getShared = false) Then in a view with layout, you can call a partial view like this PHP Code: <?= $this->extend('layout') ?> RE: CI4 beta.1 - How to load view in view with layout - eincandela - 03-12-2019 Thanks ! just what i was searching for ![]() RE: CI4 beta.1 - How to load view in view with layout - InsiteFX - 03-13-2019 You should never ever edit or add to a CodeIgniter system class file! You need to extend the class in question. RE: CI4 beta.1 - How to load view in view with layout - kilishan - 03-13-2019 A new method, include() has been added to the View system that can be used just like renderPartial above. RE: CI4 beta.1 - How to load view in view with layout - belial_seed - 03-25-2020 (03-13-2019, 09:03 PM)kilishan Wrote: A new method, include() has been added to the View system that can be used just like renderPartial above. Hello, i'm having issues with this method it reads the file but encounters a problem Code: CRITICAL - 2020-03-25 23:45:57 --> Invalid file: ci4_footer.php and the file "ci4_footer.php" contains Code: <div class="environment"> in the view Code: <footer> it's pretty simple, but i don't know where i'm making the error, any recommendation? best regards RE: CI4 beta.1 - How to load view in view with layout - aisonet - 03-12-2021 (03-13-2019, 09:03 PM)kilishan Wrote: A new method, include() has been added to the View system that can be used just like renderPartial above. When I use this method like this: PHP Code: <?php $data["name"] = ""; ?> In Views/includes/modal.php I do: PHP Code: <?php echo $name;?> Then I get an error: ErrorException Undefined variable: name How do we put variables for just the php partial page I am including, I dont want to define the partial page variables in the controller, I need to define them in the template as its building out the page html in the view RE: CI4 beta.1 - How to load view in view with layout - InsiteFX - 03-12-2021 Then create a Library and then use the View Cell Method. |