POST TIME:2017-10-26 19:52
在很多列表調用的時候都需要有隔行換色或者多行不同顏色,特別在全通式的首頁輪展圖的時候,要想實現輪展圖背景隨著圖片的更換,超過三張或多張的時候,隔行換色已經不能解決問題了,在原來的隔行換色的基礎上,進行小小的修改就可以實現這樣的功能。
列表調用隔行換色
全通式首頁輪展圖背景色更換
照片墻形式
arclist 標簽下使用 [field:global.autoindex/] 默認從1開始 channel 標簽下使用 [field:global.autoindex/] 默認從0開始 channelartlist 標簽下使用 {dede:global.itemindex/} 默認從1開始 arclist 從0開始[field:global name=autoindex runphp="yes"]@me=@me-1;[/field:global] channel 從1開始[field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global][field:typename/] channelartlist 從0開始{dede:global name=itemindex runphp='yes'}@me=@me-1;{/dede:global} channelartlist 標簽下使用 {dede:global name='itemindex' runphp='yes'}@me;{/dede:global} |
<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> </li> {/dede:list} </ul> </div> |
如果運用channel弄隔行換色,需要自增從1開始,精簡寫法如下:
<div> <ul> {dede:channel row=6 typeid=''} [field:global name=autoindex runphp="yes"]((@me+1) % 2 == 0)?@me="<li class=\"last\">":@me="<li>";[/field:global] <h4 class="title">[field:title/]</h4> </li> {/dede:channel} </ul> </div> |
<div> <ul> {dede:arclist row=6 typeid=''} [field:global name=autoindex runphp="yes"](@me % 3 == 0)?@me="<li class=\"last\">":@me="<li>";[/field:global] <h4 class="title">[field:title/]</h4> </li> {/dede:arclist} </ul> </div> |
<div> <ul> {dede:arclist typeid='8' row='6' orderby='weight'} [field:global runphp='yes' name=autoindex] $a="<li class='gd1'>"; $b="<li class='gd2'>"; $c="<li class='gd3'>"; $d="<li class='gd4'>"; $e="<li class='gd5'>"; $f="<li class='gd6'>"; if ((@me/1)==1) @me=$a; <!--調用的<li>次數(第一次調用)能被1整除,則該<li>對應$a的class='gd_1'--> else if ((@me/2)==1) @me=$b;<!--調用的<li>次數(第二次調用)能被2整除,則該<li>對應$b的class='gd_2'--> else if ((@me/3)==1) @me=$c;<!--調用的<li>次數(第三次調用)能被3整除,則該<li>對應$c的class='gd_3'--> else if ((@me/4)==1) @me=$d;<!--調用的<li>次數(第四次調用)能被4整除,則該<li>對應$d的class='gd_4'--> else if ((@me/5)==1) @me=$e;<!--調用的<li>次數(第五次調用)能被5整除,則該<li>對應$e的class='gd_5'--> else if ((@me/6)==1) @me=$f;<!--調用的<li>次數(第六次調用)能被6整除,則該<li>對應$f的class='gd_6'--> [/field:global] <div class="gdbox"> <a href="[field:arcurl/]"><img src="[field:litpic/]" width="" height="" alt='[field:title function='html2text(@me)/][field:spacename/]' /></a> <p><a href='[field:arcurl/]'>[field:title/]</a></p> </div> </li> {/dede:arclist} </ul> </div> |
精簡寫法
<div> <ul> {dede:arclist row=6 typeid=''} <li class=gd_[field:global.autoindex]> <h4 class="title">[field:title/]</h4> </li> {/dede:arclist} </ul> </div> |
這里注意每張圖的在調用的時候width和height可以為空,如果是或者亂填都沒關系,靠樣式進行定義。
<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> |