![]() |
Insert actvie css-class in a menu - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Insert actvie css-class in a menu (/showthread.php?tid=23029) |
Insert actvie css-class in a menu - El Forum - 09-27-2009 [eluser]überfuzz[/eluser] I have a menu where there are some css-classes that are showing active link. The owner of the site want to have a link marked as active as default. At the moment I muster this in the view-file like this: Code: <?php foreach ($menu AS $value) //the array menu is stated in config and holds; segment, name and atribute. I'm thinking about moving parts of this to a model called systemdata and the MY_Controller, but I'm not exactly 100% sure of how and where I should insert the active css-class. So I just have to echo-loop the menu in the view-file. Some ideas I have: 1. Put the loop in the config-file. No, I don't like to mess about with loops in config.php 2. Render it in the system model, when it's fetched from config. 3. render it in the MY_Controller, when it's received from model(system.php). 2 and 3 would mean that I have to loop through the array twice along the way just to get the menu ouput in the view-file. I've got one argument for doing it in the model, it's how I usually do this. The question would be something like, is there a nifty way of doing this..? Insert actvie css-class in a menu - El Forum - 09-28-2009 [eluser]überfuzz[/eluser] I could display the other way a was talking about, to explain my question better. Code: //view-file Code: //systemdata.php |