how to data in basecontroller.php pass to footer.php view codeigniter 4 |
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 PHP Code: return view(”template", $this->data);
Simple CI 4 project for beginners codeigniter-expenses
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?
Simple CI 4 project for beginners codeigniter-expenses
(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
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
Simple CI 4 project for beginners codeigniter-expenses
(08-03-2022, 11:54 PM)ozornick Wrote: Hmm. In CI 3 $this is "more global" as I recall.
See https://codeigniter4.github.io/CodeIgnit...o-the-view
PHP Code: return view('template', ['site_name' => $this->option->site_name]); PHP Code: <?php echo esc($site_name); ?> (08-04-2022, 12:52 AM)kenjis Wrote: See https://codeigniter4.github.io/CodeIgnit...o-the-view |
Welcome Guest, Not a member yet? Register Sign In |