帝國CMS 靈活呼叫的多圖集外掛

帝國CMS 論壇受管制被強制關站,很多技術文章都搜不到了,以前沒養成隨手記錄的習慣,現在處處不方便……

這是一直在用的一個可以靈活呼叫的多圖集功能外掛。

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]

發表評論

評論 暫無評論

文章目錄