DEDECMS implementation of the article list alternate color and random color method

Source: Internet
Author: User

Label Description:

Arclist label using [field:global.autoindex/] default starting from 1
Channel label using [field:global.autoindex/] default starting from 0
Use {dede:global.itemindex/} under Channelartlist label to start with 1

Arclist starting from 0 [Field:global name=autoindex runphp= "yes"] @me = @me-1; [/field:global]
Channel starting from 1 [field:global name=autoindex runphp= "yes"] @me = @me +1; [/field:global] [field:typename/]
Channelartlist starting from 0 {dede:global name=itemindex runphp= ' yes '} @me = @me-1; {/dede:global}

The Channelartlist label uses {dede:global name= ' itemindex ' runphp= ' yes '} @me; {/dede:global}

Alternate colors (add style), list with arclist

<div>
<ul>
{dede:list pagesize= ' 50 '}
<li>
[Field:global runphp= ' yes ' name=autoindex]
$a = "<div id= ' a ' >";
$b = "<div id= ' B ' >";
if ((@me%2) ==0) @me = $a;
else @me = $b;
[/field:global]
<span class= "date" >[[field:typelink/]][field:pubdate function= "mydate (' y-m-d ', @me)"/]</span>
<a href= "[Field:arcurl/]" >[field:title/]</a>
</div></div></li>
{/dede:list}
</ul>
</div>

If you use channel to get color, you need to start from 1, streamlined as follows:

<div>
<ul>
{Dede:channel row=6 typeid= '}
[Field:global name=autoindex runphp= "yes"] ((@me + 1)% 2 = 0)? @me = "<li class=\" last\ ">": @me = "</li><li>"; [/field:global]

</li>
{/dede:channel}
</ul>
</div>

3 lines (n lines) for color (add style) streamlined, replace orange font part

<div>
<ul>
{dede:arclist row=6 typeid= '}
[Field:global name=autoindex runphp= "yes"] (@me% 3 = 0)? @me = "<li class=\" last\ ">": @me = "</li><li>"; [/field:global]

</li>
{/dede:arclist}
</ul>
</div>
Multi-line color change (increase style)

If you want to randomly generate a color/style:

<div>
<ul>
{dede:arclist typeid= ' 8 ' row= ' 6 ' orderby= ' weight '}
[Field:global runphp= ' yes ' name=autoindex]
$a = "<li class= ' gd1 ' >";
$b = "</li><li class= ' gd2 ' >";
$c = "</li><li class= ' gd3 ' >";
$d = "</li><li class= ' gd4 ' >";
$e = "</li><li class= ' gd5 ' >";
$f = "</li><li class= ' gd6 ' >";
if ((@me/1) ==1) @me = $a; <!--the number of <li> times (first call) can be divisible by 1, then the </li><li> corresponds to $a's class= ' gd_1 '-->
else if ((@me/2) ==1) @me = $b;<!--invocation (second invocation) can be divisible by 2, then the </li><li> corresponds to $b class= ' gd_2 '-->
else if ((@me/3) ==1) @me = $c;<!--invocation (third call) can be divisible by 3, then the </li><li> corresponds to $c class= ' gd_3 '-->
else if ((@me/4) ==1) @me = $d;<!--invocation (fourth call) can be divisible by 4, then the </li><li> corresponds to $d class= ' Gd_4 '-->
else if ((@me/5) ==1) @me = $e;<!--invocation (fifth call) can be divisible by 5, then the </li><li> corresponds to $e class= ' gd_5 '-->
else if ((@me/6) ==1) @me = $f;<!--invocation (sixth call) can be divisible by 6, then the </li><li> corresponds to $f class= ' gd_6 '-->
[/field:global]
<div class= "Gdbox" >
<a href= "[field:arcurl/]" ></a>
<p><a href= ' [field:arcurl/] ' >[field:title/]</a></p>
</div>
</li>
{/dede:arclist}
</ul>
</div>

Streamlining the wording

<div>
<ul>
{dede:arclist row=6 typeid= '}
<li class=gd_[field:global.autoindex]>

</li>
{/dede:arclist}
</ul>
</div>

Common CSS Style section

<style type= "Text/css" >
. gd1{width:750px;height:330px}
. gd2{width:370px;height:165px}
. gd3{width:185px;height:165px}
. gd4{width:185px;height:165px}
. gd5{width:335px;height:247px}
. gd6{width:335px;height:247px}
. Gd1 img{width:750px;height:330px}
. GD2 img{width:370px;height:165px}
. Gd3 img{width:185px;height:165px}
. Gd4 img{width:186px;height:165px}
. Gd5 IMG{WIDTH:335PX;HEIGHT:247PX}
. Gd6 IMG{WIDTH:335PX;HEIGHT:247PX}
</style>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.