Welcome Guest, Not a member yet? Register   Sign In
Global view variables
#1

If I'm not mistaken in CodeIgniter 4 there was a method for setting variables to be available to all views.  Is it possible to do the same in CI4? An example of what I want to achieve is:
I have a logged in user name stored in a variable. I want to have it available for all header views in every method which uses the view in Dashboard controller. I guess I could just call session() in my view and pull data from there, but that's not the best way to use views, I guess. I'd rather pull the data from session somewhere once and assign it to a globally-available-for-views variable instead.
As things stand I'm passing my variables to my header view every time the view is needed in Dashboard, which results in a lot of repeated coded in controllers.
Any help on this appreciated Wink.
Reply


Messages In This Thread
Global view variables - by forumz - 07-04-2021, 03:02 PM
RE: Global view variables - by John_Betong - 07-04-2021, 10:41 PM
RE: Global view variables - by forumz - 07-05-2021, 03:37 AM
RE: Global view variables - by InsiteFX - 07-05-2021, 08:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB