首先看下效果图吧

整体思路其实就是利用dedecms的[field:array runphp='yes']这个标签的@me包含了需要的所有标签,这样就可以通过@me["litpic"]来判断文章是否有缩略图,进而分两种形式输出列表html,即有缩略图的和没有缩略图的
具体代码如下:
01 |
< style type = "text/css" > |
02 |
.arcList .itemMod{ border-bottom:dashed 1px #ccc; margin-bottom:15px; padding-bottom:15px;} |
03 |
.arcList .imgListItem{ height:130px; padding-left:215px; position:relative;} |
04 |
.arcList .img{ left:0; position:absolute; top:0;} |
05 |
.arcList .arcTit{ font-family:Microsoft Yahei; font-size:16px; font-weight:700;} |
06 |
.arcList .attrs{ height:22px; line-height:22px; margin:10px 0;} |
07 |
.arcList .click{ margin-left:50%;} |
08 |
.arcList .infos{ color:#666; font-size:12px; margin:0;} |
11 |
{dede:list pagesize='10'} |
12 |
[field:array runphp='yes'] |
13 |
if(empty(@me["litpic"]) || preg_match('/defaultpic/', @me["litpic"])){ |
14 |
@me = '< div class = "itemMod txtListItem" >< div class = "text" >< div class = "arcTit" >< a class = "t" href = "'.@me[" arcurl"].'">'.@me["fulltitle"].'</ a ></ div >< p class = "attrs" >'.GetDateTimeMK(@me["pubdate"]).'< span class = "click" >< span >点击:</ span >'.@me["click"].'</ span ></ p >< p class = "infos" >'.@me["infos"].' ... < a class = "fc_orange" href = "'.@me[" arcurl"].'" title = "'.@me[" fulltitle"].'">[全文]</ a ></ p ></ div ></ div >'; |
17 |
@me = '< div class = "itemMod imgListItem" >< a class = "img" href = "'.@me[" arcurl"].'">< img class = "lazy" src = "'.@me[" litpic"].'" width = "200" height = "130" alt = "'.@me[" fulltitle"].'" /></ a >< div class = "text" >< div class = "arcTit" >< a class = "t" href = "'.@me[" arcurl"].'">'.@me["fulltitle"].'</ a ></ div >< p class = "attrs" >'.GetDateTimeMK(@me["pubdate"]).'< span class = "click" >点击:'.@me["click"].'</ span ></ p >< p class = "infos" >'.@me["infos"].' ... < a class = "fc_orange" href = "'.@me[" arcurl"].'" title = "'.@me[" fulltitle"].'">[全文]</ a ></ p ></ div ></ div >'; |
可有可无的代码解析:
先说下样式吧,如果阁下会css完全可以根据自己的需求来定制样式,
if(empty(@me["litpic"]) || preg_match('/defaultpic/', @me["litpic"]))
这段代码就是判断是否有缩略图的,通过判断后下面就是分两种情况输出了,其实都很简单,这里说下调用字段数据,象平时都是用[field:fulltitle/],这里就要改成@me["fulltitle"],另外还有一点就是php语法的问题,细心的朋友可能已经发现了'.@me["fulltitle"].'两边都有.',也就是说@me["xxx"]是变量