CodeIgniter Forums
Menu dynamic - 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: Menu dynamic (/showthread.php?tid=76684)



Menu dynamic - mmdp8612 - 06-09-2020

Hello, I am developing a sales system using the CodeIgniter 4 framework and I ran into a problem, I need to make the menu build dynamically
 reading from a table the options so far, everything is fine, but at the time of passing it to the view I notice that I must do it from each controller as follows:

return view ('home / index.php', $ options);

But I want to avoid having to do that every time I call the view, that is, is there a way to do the load once in the view and display the menu on the rest of the screens?

I am working with templates so each view extends from a template where I include the different parts.

I thought about doing it using libraries but I didn't know how to load it from the parent template, or create a BaseController subclass and use this subclass and overload it with said functionality but I couldn't either.

I hope you understand what I need.

Thanks


RE: Menu dynamic - php_rocs - 06-09-2020

@mmdp8612,

A suggestion. Maybe generate it once and save it as a session variable Then depending on the page and or access you can determine if you need to regenerate the dynamic menu or keep it as it is.