Alternator function inside template loop - 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: Alternator function inside template loop (/showthread.php?tid=42190) |
Alternator function inside template loop - El Forum - 05-29-2011 [eluser]guidorossi[/eluser] Hi! I'm doing a list of articles with the template parser class like: Code: {articles} The idea is to user alternator() to make the zebra like list, alternating the rows colors But with that code I get always: Code: <ul class="even"> which would be the right way to do this? because it seems that the alternator function doesn't recognize the template loop as a loop Thanks! Alternator function inside template loop - El Forum - 05-29-2011 [eluser]InsiteFX[/eluser] I do it using CI Table Class and assigning a css class alt to the Table row. InsiteFX Alternator function inside template loop - El Forum - 05-29-2011 [eluser]guidorossi[/eluser] But that way you can't also use the template class, right? By not using the template class I can simply do: Code: <?php if($articles): foreach($articles as $article): ?> But as I was coding all the views using template, I just want to use for this too... Alternator function inside template loop - El Forum - 05-29-2011 [eluser]John_Betong_002[/eluser] Try this: Code: // css_file Alternator function inside template loop - El Forum - 05-29-2011 [eluser]guidorossi[/eluser] Thanks john! I've made it with: Code: //css file Thank you very much! Alternator function inside template loop - El Forum - 05-29-2011 [eluser]John_Betong_002[/eluser] I am curious to know the values of "article_name" and "article_descr". I think it is better to use "li h3 {...}" and "li p {...}" instead of replicating your classes. I think also you can apply id="articles_list" directly to your unorderd-list and eliminate the div. Code: //css file Alternator function inside template loop - El Forum - 05-30-2011 [eluser]guidorossi[/eluser] John, But each line is a <ul> in my code, and each <li> is a column. As I want each line with a different colour the way I posted I think is the best one. It's a kind of grid but without using tables, just css. My li's are display:inline Maybe I can just use tables, but I like it this way. Alternator function inside template loop - El Forum - 05-30-2011 [eluser]John_Betong_002[/eluser] It is difficult for me to picture your requirements. If it works and you are happy then no problem. Just move on to the next hurdle Alternator function inside template loop - El Forum - 05-31-2011 [eluser]cideveloper[/eluser] Just be careful. nth-child is only supported in IE9 Alternator function inside template loop - El Forum - 05-31-2011 [eluser]InsiteFX[/eluser] If you view the source code to the alternator method you will see why it doe's not work for you! InsiteFX |