帝国cms图集字段morepic字段功能使用和字段前台调用方法

时间:2023年11月10日

/

来源:网络

/

编辑:佚名

最近用帝国cms做商城,因为商城会有一个图片展示功能,如下图:

然后看了帝国cms中商城也并没有这个功能,考虑自己新建个字段来实现,最终考虑使用帝国图集中的morepic代码作为后台图集输入代码:
<script>
function dopicadd()
{var i;
var str="";
var oldi=0;
var j=0;
oldi=parseInt(document.add.morepicnum.value);
for(i=1;i<=document.add.downmorepicnum.value;i++)
{
j=i+oldi;
str=str+"<tr><td width=7%><div align=center>"+j+"</div></td><td width=33%><div align=center><input name=msmallpic[] type=text size=28 id=msmallpic"+j+" ondblclick=SpOpenChFile(1,'msmallpic"+j+"')><br><input type=file name=msmallpfile[] size=15></div></td><td width=30%><div align=center><input name=mbigpic[] type=text size=28 id=mbigpic"+j+" ondblclick=SpOpenChFile(1,'mbigpic"+j+"')><br><input type=file name=mbigpfile[] size=15></div></td><td width=30%><div align=center><input name=mpicname[] type=text></div></td></tr>";
}
document.getElementById("addpicdown").innerHTML="<table width='100%' border=0 cellspacing=1 cellpadding=3>"+str+"</table>";
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25">
图片地址前缀:
<input name="mpicurl_qz" type="text" id="mpicurl_qz">&nbsp;&nbsp;
<input type="checkbox" name="msavepic" value="1">远程保存&nbsp;<input type="checkbox" name="mcreatespic" value="1" onclick="if(this.checked){setmcreatespic.style.display='';}else{setmcreatespic.style.display='none';}">生成缩图
<span id="setmcreatespic" style="display:none">:<input type=text name="mcreatespicwidth" size=4 value="<?=$public_r[spicwidth]?>">*<input type=text name="mcreatespicheight" size=4 value="<?=$public_r[spicheight]?>">(宽*高)</span>
<?php
if(TranmoreIsOpen())
{
?>
<input type="button" name="Submit" value="多选上传" onclick="window.open('ecmseditor/tranmore/tranmore.php?type=1&classid=<?=$classid?>&filepass=<?=$filepass?>&infoid=<?=$id?>&modtype=0&sinfo=1&ecmsdo=ecmstmmorepic&tranfrom=2<?=$ecms_hashur['ehref']?>&oldmorepicnum='+document.add.morepicnum.value,'ecmstmpage','width=700,height=550,scrollbars=yes');">
<?php
}
?>
</td>
</tr>
<tr>
<td><table width="100%" border=0 align=center cellpadding=3 cellspacing=1>
<tr bgcolor="#DBEAF5">
<td width="7%"><div align=center>编号</div></td>
<td width="33%"><div align=center>缩图 <font color="#666666">(双击选择)</font></div></td>
<td width="30%"><div align=center>大图 <font color="#666666">(双击选择)</font></div></td>
<td width="30%"><div align=center>图片说明</div></td>
</tr>
</table></td>
</tr>
<tr>
<td id=defmorepicid>
<?php
if($ecmsfirstpost==1)
{
?>
<table width='100%' border=0 align=center cellpadding=3 cellspacing=1>
<?php
$morepicnum=3;
for($mppathi=1;$mppathi<=$morepicnum;$mppathi++)
{
?>
<tr>
<td width='7%'><div align=center><?=$mppathi?></div></td>
<td width='33%'><div align=center>
<input name=msmallpic[] type=text id='msmallpic<?=$mppathi?>' size=28 ondblclick="SpOpenChFile(1,'msmallpic<?=$mppathi?>');">
<br><input type=file name=msmallpfile[] size=15>
</div></td>
<td width='30%'><div align=center>
<input name=mbigpic[] type=text id='mbigpic<?=$mppathi?>' size=28 ondblclick="SpOpenChFile(1,'mbigpic<?=$mppathi?>');">
<br><input type=file name=mbigpfile[] size=15>
</div></td>
<td width='30%'><div align=center>
<input name=mpicname[] type=text id='mpicname<?=$mppathi?>'>
</div></td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
$morepicpath="";
$morepicnum=0;
if($r[morepic])
{
$r[morepic]=stripSlashes($r[morepic]);
//地址
$j=0;
$pd_record=explode("\r\n",$r[morepic]);
for($i=0;$i<count($pd_record);$i++)
{
$j=$i+1;
$pd_field=explode("::::::",$pd_record[$i]);
$morepicpath.="<tr>
<td width='7%'><div align=center>".$j."</div></td>
<td width='33%'><div align=center>
<input name=msmallpic[] type=text value='".$pd_field[0]."' size=28 id=msmallpic".$j." ondblclick=\"SpOpenChFile(1,'msmallpic".$j."');\">
<br><input type=file name=msmallpfile[] size=15>
</div></td>
<td width='30%'><div align=center>
<input name=mbigpic[] type=text value='".$pd_field[1]."' size=28 id=mbigpic".$j." ondblclick=\"SpOpenChFile(1,'mbigpic".$j."');\">
<br><input type=file name=mbigpfile[] size=15>
</div></td>
<td width='30%'><div align=center>
<input name=mpicname[] type=text value='".$pd_field[2]."'><input type=hidden name=mpicid[] value=".$j."><input type=checkbox name=mdelpicid[] value=".$j.">删
</div></td>
</tr>";
}
$morepicnum=$j;
$morepicpath="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$morepicpath."</table>";
}
echo $morepicpath;
}
?>
</td>
</tr>
<tr>
<td height="25">地址扩展数量: <input name="morepicnum" type="hidden" id="morepicnum" value="<?=$morepicnum?>">
<input name="downmorepicnum" type="text" value="1" size="6"> <input type="button" name="Submit5" value="输出地址" onclick="javascript:dopicadd();"></td>
</tr>
<tr>
<td id=addpicdown></td>
</tr>
</table>

这个的优势是我可以多张图片,每一个商品图片数量不一定的情况下都可以灵活输入,同时图片的地址可以用自己上传图片的方式,也可以调用其他网站图片方式,非常灵活 在用了上面的帝国cms图集代码后,在前段模板页面采用下面的代码进行切割整个morepic中的字段,然后同时还能自定义前段的样式。

<?php
$arr = array();
$arr = $navinfor['morepic'];
$newarr = explode(egetzy('rn'),$arr);
$count = count(explode(egetzy('rn'),$navinfor[morepic]));//图集的图片数量 
for($i=0;$i<$count;$i++)
{
$s_arr = array();
$s_arr[] = $newarr[$i];
$str = $s_arr[0];
$bot_arr = explode("::::::", $str);
$spic = $bot_arr[0];//小图
$bpic = $bot_arr[1];//大图
$picinfo = $bot_arr[2];//图片说明
echo '<img src="'.$spic.'" data-large="'.$bpic.'" alt="'.$picinfo.'" width="65" height="65" />';
}
?>
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。