kingsinnersoul Posted July 9, 2013 Share Posted July 9, 2013 (edited) Hello, I am want to have different colors for even and odd iterations of the product features in the Data-Sheet tab in the product page. I modified the product.tpl file and added after {foreach from=$features item=feature} {if isset($feature.value)} this IF statement {if $feature@iteration is odd by 1} but it only detected the first row as odd, and the rest of the features were given the result of the {else} statement. I even tried add key=i to the foreach statement, and then adding {if $i%2==1} but it detected one line and the rest were given the results from the {else} statement. How can I currectly force different style/layout which depends on the iteration of the foreach loop? PS. I am using prestashop 1.5.4.1 Thanks Edited July 9, 2013 by kingsinnersoul (see edit history) Link to comment Share on other sites More sharing options...
Dh42 Posted July 9, 2013 Share Posted July 9, 2013 I think you might be going at it wrong. I am not positive, because I have never tried it, but it seems like you could use css psuedo classes to do it. Read this, scroll down to nth-child http://coding.smashingmagazine.com/2011/03/30/how-to-use-css3-pseudo-classes/ 1 Link to comment Share on other sites More sharing options...
kingsinnersoul Posted July 9, 2013 Author Share Posted July 9, 2013 You made it look so easy :-) Thanks, it works. But still out of curiousity, what is the way to achieve the same result using smarty? Link to comment Share on other sites More sharing options...
kingsinnersoul Posted July 9, 2013 Author Share Posted July 9, 2013 Now I am facing a different issue/problem. I chagned the features from a list to a table with each row having different colors and name and value are on different cells. The table shows on both the More Info tab and the Data Sheet tab. What am I doing wrong? Thanks Link to comment Share on other sites More sharing options...
Dh42 Posted July 9, 2013 Share Posted July 9, 2013 I wouldn't know without looking at it. To answer you other question, to make them targetable with standard css, it will produce this http://screencast.com/t/ubB7k9YZnmQ If you use this, http://screencast.com/t/xxjhyJcp Link to comment Share on other sites More sharing options...
kingsinnersoul Posted July 9, 2013 Author Share Posted July 9, 2013 (edited) Well, it was my error. I added display:block, and that removed the display:none. Once I removed the CSS it worked like a charm. Your solution is good if I want to target any specific item in the list. But will it enable me to check for odd/even ones by doing: {if ($smarty.foreach.count.index)%2==1} and why the is even/odd by I tried using originally did not work for me? What was I doing wrong there? Thank you Edited July 9, 2013 by kingsinnersoul (see edit history) Link to comment Share on other sites More sharing options...
Dh42 Posted July 9, 2013 Share Posted July 9, 2013 I am honestly not that great with smarty... I do not know. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now