![]() |
how to keep the variable passed to the view in 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 keep the variable passed to the view in codeigniter 4 (/showthread.php?tid=81414) |
how to keep the variable passed to the view in codeigniter 4 - startup - 02-25-2022 in my controller Home.php PHP Code: class HomeController extends BaseController{ in my view.php PHP Code: $demo =$mHome->myFunction($id); thank you @ikesela, sometime is sptupid, i fix code above this, it working PHP Code: class HomeController extends BaseController{ RE: how to keep the variable passed to the view in codeigniter 4 - ikesela - 02-26-2022 just pass the object: Code: return view('\Modules\Site\Home\Views\home_index', [ 'mHome' => new HomeModel() ]); RE: how to keep the variable passed to the view in codeigniter 4 - iRedds - 02-26-2022 You don't need to pass the model to the view. This is bad practice. RE: how to keep the variable passed to the view in codeigniter 4 - startup - 02-26-2022 (02-26-2022, 01:22 AM)iRedds Wrote: You don't need to pass the model to the view. PHP Code: cateMenu =1 can you good method to get id folow cate in view page ? i know 'view_ceil' in codeigniter 4 , but id dont like this function RE: how to keep the variable passed to the view in codeigniter 4 - ikesela - 02-26-2022 (02-26-2022, 01:22 AM)iRedds Wrote: You don't need to pass the model to the view. Thank, i agree . RE: how to keep the variable passed to the view in codeigniter 4 - iRedds - 02-26-2022 (02-26-2022, 01:54 AM)startup Wrote:(02-26-2022, 01:22 AM)iRedds Wrote: You don't need to pass the model to the view. I don't know the logic of your application. For example, you can create a service that will prepare data for display. This is a simple example to show the concept. PHP Code: class MyService |