A Multi-Image Gallery Plugin You Can Call Anywhere in Empire CMS

The Empire CMS forum was shut down under restrictions, and a lot of the technical threads are gone for good. I never got into the habit of writing things down as I went, which I'm paying for now.

Here's a multi-image gallery plugin I've relied on for years — one you can call from anywhere.

1. Copy the code below into userfun.php (the file lives at /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;
    
    // Load the template
    $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;}
    
    // Build the list
    $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";    // Thumbnail
        $bigpic=$fr[1]?$fr[1]:$public_r[newsurl]."e/data/images/notimg.gif";    // Full-size image
        if(empty($bigpic))
        {
            $bigpic=$smallpic;
        }
        $picname=htmlspecialchars($fr[2]);    // Title
        $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;
        // Row limit reached
        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. Add the tag
Tag name: Gallery
Tag symbol: pichd
Function: user_PhotoMorepic
Tag format: [pichd]tempid[/pichd]
(tempid is the template tag ID)

3. Tag templates:
Page template content:
list header[!--empirenews.listtemp--]list item[!--empirenews.listtemp--]list footer

List item template (list.var)
[!--picname--] Image caption (title)
[!--smallpic--] Thumbnail
[!--bigpic--] Full-size image
[!--no.num--] Item number

Content template
[pichd]template tag id[/pichd]

Leave a Comment

Comments No Comments

Table of Contents