html helper: ul (Alternating row colors) |
[eluser]BigBonsai[/eluser]
Hello, is it possible to give the <li>-points of the ul($array) output alternating colors? This would result in each row being more readable. Or would I have to edit the html_helper to do that? Or is there a better way to output arrays in separate rows? Thanks in advance. BiB
[eluser]Stefan Hueg[/eluser]
Here you go: Code: <style type="text/css"> (the span had to be inserted because you will have to reset the color of the text)
[eluser]BigBonsai[/eluser]
Well, that works if I create the UL manually. I was wondering if it is possible to do the alternating thing - as you showed it nicely - with the ul() function. BiB
[eluser]GrahamDj28[/eluser]
Hi, There is a way you can do what you want to do. Create a file in application/helpers/ and call it MY_html_helper.php (if you have changed the file prefix in your config, then use what you have defined there instead of MY_) Then copy the the following functions to that file: You will find these functions in system/helpers/html_helper.php Code: if ( ! function_exists('ul')) Code: if ( ! function_exists('ol')) Code: if ( ! function_exists('_list')) Update the last function to fit your needs. E.g. you can add a counter which is used to set the correct class on the <li> And for the CSS given, instead of color, you can use background to set the background color. Color is used for the font coloring. Using background you also do not need to reset the text color with a span
[eluser]Aken[/eluser]
If 100% browser compatibility isn't a requirement, you can do it using CSS alone. Code: ul li { color: black; }
[eluser]BigBonsai[/eluser]
I didn't think anyone would still have a solution. Thank you very much!!! I will experiment with both. Great stuff! BiB
[eluser]InsiteFX[/eluser]
css file Code: // change color to what you want. ./application/helpers/MY_html_helper.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
[eluser]Aken[/eluser]
There's also the alternator() helper function. http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]Near[/eluser]
Code: <$cript>
|
Welcome Guest, Not a member yet? Register Sign In |