帝国CMS灵活调用个性化的多图片集插件

帝国CMS论坛受管制,强制关闭了,很多技术贴内容无法搜到,之前没养成随手记的习惯,导致现在诸多的不便...
ECMS的图集效果不太理想,一直在用的一个可以灵活调用的多图集功能插件。

1、功能代码

将下面的代码,复制到你的userfun.php中(文件位置:/e/class/userfun.php)

function user_PhotoMorepic($tempid){
    global $navinfor,$public_r;
    $morepic=$navinfor['morepic'];
    $rexp="\r\n";
    $fexp="::::::";
    $rstr="";
    $sdh="";
    $w_morepic="";
    $rr=explode($rexp,$morepic);
    $count=count($rr);
    $num=$count;
    
    //取得模板
    $tr=sys_ReturnBqTemp($tempid);
    if(empty($tr['tempid']))
    {return "";}
    $listtemp=str_replace('[!--news.url--]',$public_r[newsurl],$tr[temptext]);
    $subnews=$tr[subnews];
    $listvar=str_replace('[!--news.url--]',$public_r[newsurl],$tr[listvar]);
    $rownum=$tr[rownum];
    $formatdate=$tr[showdate];
    if(empty($rownum))
    {$rownum=1;}
    
    //列表
    $list_exp="[!--empirenews.listtemp--]";
    $list_r=explode($list_exp,$listtemp);
    $listtext=$list_r[1];
    $no=1;
    $changerow=1;
    
    for($i=0;$i<$count;$i++)
    {
        $fr=explode($fexp,$rr[$i]);
        $smallpic=$fr[0]?$fr[0]:$public_r[newsurl]."e/data/images/notimg.gif";    //小图
        $bigpic=$fr[1]?$fr[1]:$public_r[newsurl]."e/data/images/notimg.gif";    //大图
        if(empty($bigpic))
        {
            $bigpic=$smallpic;
        }
        $picname=htmlspecialchars($fr[2]);    //名称
        $val[picname]=$picname;
        $val[bigpic]=$bigpic;
        $val[smallpic]=$smallpic;
        /////////////////
        $strF=",picname,bigpic,smallpic,";
        $repvar=user_ReplaceShowpicsVars($listvar,$strF,$val,$no);
        $listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
        $changerow+=1;
        //超过行数
        if($changerow>$rownum)
        {
        $changerow=1;
        $string.=$listtext;
        $listtext=$list_r[1];
        }
        $no++;
    }
   $string=$list_r[0].$string.$list_r[2];
    echo $string;
}

function user_ReplaceShowpicsVars($listtemp,$strF,$val,$no){
$fr=explode(',',$strF);
$fcount=count($fr)-1;;
for($i=1;$i<$fcount;$i++)
{
$f=$fr[$i];
$value=$val[$f];
$listtemp=str_replace('[!--'.$f.'--]',$value,$listtemp);
}
$listtemp=str_replace('[!--no.num--]',$no,$listtemp);

return $listtemp;
}

2、添加标签

标签名:图集
标签符号:pichd
函数名:user_PhotoMorepic
标签格式:[pichd]tempid[/pichd]
(tempid为模板标签id)

3、标签模板

页面模板内容:
列表头[!--empirenews.listtemp--]列表内容[!--empirenews.listtemp--]列表尾

列表内容模板(list.var)
[!--picname--] 图片说明(标题)
[!--smallpic--] 小图
[!--bigpic--] 大图
[!--no.num--] 序号

内容模板
[pichd]标签模板id[/pichd]

本文转自:https://nipang.cn/ecms-PhotoMorepic.html

评论已关闭