how to data in basecontroller.php pass to footer.php view codeigniter 4 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: how to data in basecontroller.php pass to footer.php view codeigniter 4 (/showthread.php?tid=82638) |
how to data in basecontroller.php pass to footer.php view codeigniter 4 - startup - 08-03-2022 1. BaseController.php PHP Code: <?php 2.footer.php PHP Code: <?php echo $this->site_name; ?> NOTE FOR SOMEONE NEED i only write demo, if you do your project, you can write method function to show 1. in BaseController.php PHP Code: <?php in footer.php we show this PHP Code: <?php RE: how to data in basecontroller.php pass to footer.php view codeigniter 4 - ozornick - 08-03-2022 PHP Code: return view(”template", $this->data); RE: how to data in basecontroller.php pass to footer.php view codeigniter 4 - startup - 08-03-2022 (08-03-2022, 11:04 PM)ozornick Wrote: #ozornick ,no, I mean without controller but still showing data in the footer.php, in codeigniter 3 can do this, ci4 cant do this RE: how to data in basecontroller.php pass to footer.php view codeigniter 4 - ozornick - 08-03-2022 In what situation is the template called without a controller? If this is some private information output, it must be passed to the method. Do you have a working use case? RE: how to data in basecontroller.php pass to footer.php view codeigniter 4 - startup - 08-03-2022 (08-03-2022, 11:22 PM)ozornick Wrote: In what situation is the template called without a controller? in codeigniter 3, i only write code in my_controller view footer.php do like $demo =$this->option ->myfunction(); echo $demo->site_name RE: how to data in basecontroller.php pass to footer.php view codeigniter 4 - ozornick - 08-03-2022 Hmm. In CI 3 $this is "more global" as I recall. For your last example, the function should return something (object). PHP Code: // in my_function(), example I can’t guess anymore, expect others or try it yourself RE: how to data in basecontroller.php pass to footer.php view codeigniter 4 - startup - 08-04-2022 (08-03-2022, 11:54 PM)ozornick Wrote: Hmm. In CI 3 $this is "more global" as I recall. RE: how to data in basecontroller.php pass to footer.php view codeigniter 4 - kenjis - 08-04-2022 See https://codeigniter4.github.io/CodeIgniter4/outgoing/views.html#adding-dynamic-data-to-the-view PHP Code: return view('template', ['site_name' => $this->option->site_name]); PHP Code: <?php echo esc($site_name); ?> RE: how to data in basecontroller.php pass to footer.php view codeigniter 4 - startup - 08-04-2022 (08-04-2022, 12:52 AM)kenjis Wrote: See https://codeigniter4.github.io/CodeIgniter4/outgoing/views.html#adding-dynamic-data-to-the-view |