How to use public variables from controller in views in CI 4 |
@John_Betong, I'm really sorry to say that I didn't understand what you mean.
@includebeer, thanks for your suggestion. But in this case, I'll have to pass $this->data with every view(). And beside this, I couldn't use $this->my_variable in views. Which I've in CI3.
(12-30-2020, 07:12 AM)ciddict Wrote: @John_Betong, I'm really sorry to say that I didn't understand what you mean. Even if you have 50 views, how hard is it to pass $this->data to all your view and use $my_variable instead of $this->my_variable? Do you really think that converting a CI3 application to CI4 is just 2-3 fix here and there that you can do in 5 minutes? Do it the right way or don't do it at all. I don't know what development experience you have, but this is super easy to do and this is how you should have done it even in CI3.
Hmm, seems it won't be easy as you saying. I haven't much development experience. Thanks for your reply.
@ciaddict
> I didn’t understand... Do you know how to use the Base_Controller? In the Base_Controller index method define(‘MY_CONSTANT’, ‘with an array, string, integer, bool or object’); To show in the view: <?= MY_CONSTANT ?>
@John_Betong, Yes got it now. Maybe this'll be the best solution for me. Thank you so much.
|
Welcome Guest, Not a member yet? Register Sign In |