百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>织梦CMS教程> dedecms织梦网站程序列表页完成隔行_多行随便换色
分享文章到:

dedecms织梦网站程序列表页完成隔行_多行随便换色

发布时间:04/15 来源:未知 浏览: 关键词:
dedecms织梦网站程序列表页完成隔行_多行随便换色标签说明:
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} 
隔行换色(增加样式),list同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>
 </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>
隔3行(n行)换色(增加样式)精简写法,替换橙色字体部分
 <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>
多行随意换色(增加样式)
      如果想随机生成彩色/样式,可以参考文章《dede优化方法整理之:tag标签》
 <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>
公共css样式部分
      这里注意每张图的在调用的时候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>
打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有186人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板