CLASS attribute on <li/> using HTML Helper |
[eluser]Design Software[/eluser]
Hi all, i need to know how to set any attripute on a <li/> tag using function ul() or ol() from HTML Helper. Thanks. Marco
[eluser]drewbee[/eluser]
http://ellislab.com/codeigniter/user-gui...elper.html From the manual...... Code: $this->load->helper('html');
[eluser]Design Software[/eluser]
I mean attributes to <li/> tag not <ul/> one...
[eluser]drewbee[/eluser]
Oops. My apologies. I read it too fast. It looks like it does not currently support attributes on the LI level. From the function _list which is called by function ol or ul. Code: foreach ($list as $key => $val) Perhaps feature request? It doesn't seem like it would be that hard to do, I would create another array of li attributes. IE: Code: $list = array('red', 'green', 'blue' = array('light blue')); The value will be an array if $val is an array, so use the key instead. Code: foreach ($list as $key => $val) Make sure you add in a third parameter to accept $li_attributes to the ol/li function and pass it to the list function. I'm pretty sure this will work for flat arrays, not to sure how it will handle multi-dimensional arrays... Dig in!!
[eluser]Design Software[/eluser]
Maybe i don't understand, this is my test: Code: $list = array( where i'm wrong? Thanks
[eluser]InsiteFX[/eluser]
Thats because you need to run your $list through drewbee's foreach loop above then echo $out
[eluser]drewbee[/eluser]
Yup. You need to 'extend' the _list function from the form_helper
[eluser]Design Software[/eluser]
Hi all, i solved this problem by creating an helper with the following code: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ...it works but only with "flat" arrays. Thanks for your interest
[eluser]Lykos22[/eluser]
@Everett Myers: I'm using CI 2.1.4 and tried to follow the example you 've posted, but the _list() function doesn't seem to work properly. What I'm trying to achieve is to create a navigation menu like this: Code: <ul class="page-sidebar-menu" data-auto-scroll="false" data-auto-speed="200">
[eluser]Lykos22[/eluser]
Eventually I found out what I was doing wrong. As the [url="http://ellislab.com/codeigniter/user-guide/general/helpers.html"]user guide[/url] says, the _list() function should be extended. So I saved it inside ./application/helpers/MY_html_helper.php, and this did the trick for me! p.s. This is definately something that would be great to put in system folder on future versions. |
Welcome Guest, Not a member yet? Register Sign In |