discuz X3.4的门户文章列表页多图显示



门户列表页模板里找到

  1. <!--{loop $list['list'] $value}-->
    <!--{eval $highlight = article_title_style($value);}-->
    <!--{eval $article_url = fetch_article_url($value);}-->

复制代码

在它下面加上

  1. <!--{eval $article_pic_num=DB::result_first("SELECT count(attachid) FROM ".DB::table("portal_attachment")." WHERE `aid`='$value[aid]'");}-->
    <!--{if $article_pic_num > 0 && $article_pic_num < 4}-->
    <!--{eval $pic_limit = '1';}-->
    <!--{elseif $article_pic_num > 3 && $article_pic_num < 8}-->
    <!--{eval $pic_limit = '4';}-->
    <!--{elseif $article_pic_num > 7}-->
    <!--{eval $pic_limit = '4';}-->
    <!--{/if}-->
    <!--{if $article_pic_num > 0}-->
    <!--{eval $article_pic_list=DB::fetch_all("SELECT attachment,attachid,filename FROM ".DB::table("portal_attachment")." WHERE `aid`='$value[aid]' ORDER BY `attachid` DESC LIMIT 0,$pic_limit;");}-->
    <!--{/if}-->
    <!--{eval $article_all=DB::result_first("select content from ".DB::table("portal_article_content")." where aid='$value[aid]'");}-->
    <!--{eval preg_match_all("/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/", $article_all, $ex_pic);}-->
    <!--{eval $ex_pic_num = count($ex_pic[1]);}-->
    <!--{if $ex_pic_num > 0 && $ex_pic_num < 4}-->
    <!--{eval $ex_pic_num = '1';}-->
    <!--{elseif $ex_pic_num > 3}-->
    <!--{eval $ex_pic_num = '4';}-->
    <!--{/if}-->
    <div class="article_loop {if $pic_limit == 4}pic_4{/if} cl">
            <!--{if $pic_limit == 1}-->
            <div class="content_body">
                    <a href="$article_url" title="$value[title]"><img src="$value[pic]" alt="$value[title]"></a>        
            </div>
            <!--{elseif $ex_pic_num == 1 && $pic_limit == 0}-->
            <div class="content_body">
                    <a href="$article_url" title="$value[title]"><img src="$ex_pic[1][0]" alt="$value[title]"></a>        
            </div>
            <!--{/if}-->
            <div class="content_infor">
            <h2><a href="$article_url" target="_blank" class="xi2" $highlight>$value[title]</a> <!--{if $value[status] == 1}-->({lang moderate_need})<!--{/if}--></h2>
            <!--{if $pic_limit > 3}-->
            <div class="more_pic cl">
                    <!--{loop $article_pic_list $picvalue}-->
                    <a href="portal.php?mod=view&aid={$value['aid']}#{$picvalue['attachid']}" title="" target="" class="success"><img src="data/attachment/portal/{$picvalue['attachment']}" alt="{$picvalue['filename']}"></a>
                    <!--{/loop}-->
            </div>
            <!--{elseif $ex_pic_num > 3 && $pic_limit == 0}-->
            <!--{eval $i=1;}-->
            <div class="more_pic cl">
                    <!--{loop $ex_pic[1] $ex_picvalue}-->
                    <!--{if $i<5}-->
                    <a href="portal.php?mod=view&aid={$value['aid']}" title="" target="" class="success"><img src="{$ex_picvalue}" alt=""></a>
                    <!--{/if}-->
                    <!--{eval $i++;}-->
                    <!--{/loop}-->
            </div>
            <!--{/if}-->
            <span class="time"><i class="fa fa-clock-o fa-fw"></i>{$value[dateline]}</span>
            <span class="pipe"></span>
            <span class="views"><i class="fa fa-eye fa-fw"></i>{$value[viewnum]}</span>
            <span class="pipe"></span>
            <span class="reply"><i class="fa fa-comment-o fa-fw"></i>{$value[commentnum]}</span>
            <p>$value[summary]......</p>
    </div>
    </div>
    

上面有两处数字有点问题的,一个是pic_limit判断两次等于4,是因为我模板显示8张图不好看,否则下面的4应该是8。改成8之后,下面的外链图片数量判断也要改。
很多代码可以写在一起,为了方便看逻辑分开写了。

五月源码网 discuz教程 discuz X3.4的门户文章列表页多图显示 https://www.u532.com/1306.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务