Home >CMS Tutorial >DEDECMS >How to achieve 'interlaced color change' in Dream Weaver List
How to achieve "interlaced color change" in Dream Weaver List
When building a corporate website or portal website, I often It is necessary to achieve the effect of changing colors on alternate rows in the article list. The method is very simple. Let’s take a look at the implementation method.
The sample code is as follows:
{dede:arclist row='12' titlelen='33' typeid='1' orderby ='pubdate'} [field:global runphp='yes' name=autoindex] $adminbuy.cn_a="<li class='adminbuy.cn_c'>"; $adminbuy.cn_b="<li class=''adminbuy.cn_d'>"; if ((@me%2)==0) @me=$'adminbuy.cn_a; else @me=$'adminbuy.cn_b; [/field:global] <a href='[field:arcurl/]'>[field:title/]</a> </li> {/dede:arclist}
As can be seen from the above example:
This code uses autoindex to increase automatically, and the number of self-increment is the same as 2 Take the modulus. When the self-increasing number %2==0 means that the self-increasing number can be divisible by 2, it is true and outputs $'adminbuy.cn_a. The code at this time It is false when
{dede:arclist row='12' titlelen='33' typeid='1' orderby ='pubdate'} <li class=''adminbuy.cn_c'><a href='[field:arcurl/]'>[field:title/]</a></li> {/dede:arclist}
is not divisible by 2, output $'adminbuy.cn_b, the code at this time is:
{dede:arclist row='12' titlelen='33' typeid='1' orderby ='pubdate'} <li class=''adminbuy.cn_d'><a href='[field:arcurl/]'>[field:title/]</a></li> {/dede:arclist}
by outputting the difference in the li tag The class style (two styles of 2l3.net_c and 2l3.net.com_d need to be defined in css) can realize interlaced color changing.
Recommended tutorial: dedecms tutorial
The above is the detailed content of How to achieve 'interlaced color change' in Dream Weaver List. For more information, please follow other related articles on the PHP Chinese website!