帝国cms模型修改添加多个图集字段
2024-08-28 12:25:42
供稿:网友
因为 最近做站一个模型里有两个字段均为图集形式的,帝国虽然有图集模块,但不能实现多个字段是图集,所以稍微改造了一下 下面效果图
1.首先按正常步骤,在对应模型里加上相应字段 这里我习惯遵从原来图集系统起名 mobanpic, 管理字段-》修改 -》输入表单替换html代码 将我下面这段代码复制进去
注意下面代码中 把"moban"字段替换成自己对应的名称,我这里字段名为mobanpic
<script>
function domobanpicadd()
{var i;
var str="";
var oldi=0;
var j=0;
oldi=parseInt(document.add.mobanpicnum.value);
for(i=1;i<=document.add.downmobanpicnum.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=msmallmobanpic[] type=text size=28 id=msmallmobanpic"+j+" ondblclick=SpOpenChFile(1,'msmallmobanpic"+j+"')><br><input type=file name=msmallmobanpfile[] size=15></div></td><td width=30%><div align=center><input name=mbigmobanpic[] type=text size=28 id=mbigmobanpic"+j+" ondblclick=SpOpenChFile(1,'mbigmobanpic"+j+"')><br><input type=file name=mbigmobanpfile[] size=15></div></td><td width=30%><div align=center><input name=mmobanpicname[] type=text></div></td></tr>";
}
document.getElementById("addmobanpicdown").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="mmobanpicurl_qz" type="text" id="mmobanpicurl_qz">
<input type="checkbox" name="msavemobanpic" value="1">远程保存 <input type="checkbox" name="mcreatesmobanpic" value="1" onclick="if(this.checked){setmcreatesmobanpic.style.display='';}else{setmcreatesmobanpic.style.display='none';}">生成缩图
<span id="setmcreatesmobanpic" "display:none">:<input type=text name="mcreatesmobanpicwidth" 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=ecmstmmobanpic&tranfrom=2<?=$ecms_hashur['ehref']?>&oldmobanpicnum='+document.add.mobanpicnum.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=defmobanpicid>
<?php
if($ecmsfirstpost==1)
{
?>
<table width='100%' border=0 align=center cellpadding=3 cellspacing=1>
<?php
$mobanpicnum=3;
for($mppathi=1;$mppathi<=$mobanpicnum;$mppathi++)
{
?>
<tr>
<td width='7%'><div align=center><?=$mppathi?></div></td>
<td width='33%'><div align=center>
<input name=msmallmobanpic[] type=text id='msmallmobanpic<?=$mppathi?>' size=28 ondblclick="SpOpenChFile(1,'msmallmobanpic<?=$mppathi?>');">
<br><input type=file name=msmallmobanpfile[] size=15>
</div></td>
<td width='30%'><div align=center>
<input name=mbigmobanpic[] type=text id='mbigmobanpic<?=$mppathi?>' size=28 ondblclick="SpOpenChFile(1,'mbigmobanpic<?=$mppathi?>');">
<br><input type=file name=mbigmobanpfile[] size=15>
</div></td>
<td width='30%'><div align=center>
<input name=mmobanpicname[] type=text id='mmobanpicname<?=$mppathi?>'>
</div></td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
$mobanpicpath="";
$mobanpicnum=0;
if($r[mobanpic])
{
$r[mobanpic]=stripSlashes($r[mobanpic]);
//地址
$j=0;
$pd_record=explode("/r/n",$r[mobanpic]);
for($i=0;$i<count($pd_record);$i++)
{
$j=$i+1;
$pd_field=explode("::::::",$pd_record[$i]);
$mobanpicpath.="<tr>
<td width='7%'><div align=center>".$j."</div></td>
<td width='33%'><div align=center>
<input name=msmallmobanpic[] type=text value='".$pd_field[0]."' size=28 id=msmallmobanpic".$j." ondblclick=/"SpOpenChFile(1,'msmallmobanpic".$j."');/">
<br><input type=file name=msmallmobanpfile[] size=15>
</div></td>
<td width='30%'><div align=center>
<input name=mbigmobanpic[] type=text value='".$pd_field[1]."' size=28 id=mbigmobanpic".$j." ondblclick=/"SpOpenChFile(1,'mbigmobanpic".$j."');/">
<br><input type=file name=mbigmobanpfile[] size=15>
</div></td>
<td width='30%'><div align=center>
<input name=mmobanpicname[] type=text value='".$pd_field[2]."'><input type=hidden name=mmobanpicid[] value=".$j."><input type=checkbox name=mdelmobanpicid[] value=".$j.">删
</div></td>
</tr>";
}
$mobanpicnum=$j;
$mobanpicpath="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$mobanpicpath."</table>";
}
echo $mobanpicpath;
}
?>
</td>
</tr>
<tr>
<td height="25">地址扩展数量: <input name="mobanpicnum" type="hidden" id="mobanpicnum" value="<?=$mobanpicnum?>">
<input name="downmobanpicnum" type="text" value="1" size="6"> <input type="button" name="Submit5" value="输出地址" onclick="javascript:domobanpicadd();"></td>
</tr>
<tr>
<td id=addmobanpicdown></td>
</tr>
</table>
将下面代码复制进 投稿表单替换html代码 和上面的处理方法一样
<script>
function domobanpicadd()
{var i;
var str="";
var oldi=0;
var j=0;
oldi=parseInt(document.add.mobanpicnum.value);
for(i=1;i<=document.add.downmobanpicnum.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=msmallmobanpic[] type=text size=28 id=msmallmobanpic"+j+"></div></td><td width=30%><div align=center><input name=mbigmobanpic[] type=text size=28 id=mbigmobanpic"+j+"></div></td><td width=30%><div align=center><input name=mmobanpicname[] type=text></div></td></tr>";
}
document.getElementById("addmobanpicdown").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="mmobanpicurl_qz" type="text" id="mmobanpicurl_qz" size="32">
</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>缩图</div></td>
<td width=30%><div align=center>大图</div></td>
<td width=30%><div align=center>图片说明</div></td>
</tr>
</table></td>
</tr>
<tr>
<td id=defmobanpicid>
<?php
if($ecmsfirstpost==1)
{
?>
<table width='100%' border=0 align=center cellpadding=3 cellspacing=1>
<?php
$mobanpicnum=3;
for($mppathi=1;$mppathi<=$mobanpicnum;$mppathi++)
{
?>
<tr>
<td width='7%'><div align=center><?=$mppathi?></div></td>
<td width='33%'><div align=center>
<input name=msmallmobanpic[] type=text id=msmallmobanpic[] size=28>
</div></td>
<td width='30%'><div align=center>
<input name=mbigmobanpic[] type=text id=mbigmobanpic[] size=28>
</div></td>
<td width='30%'><div align=center>
<input name=mmobanpicname[] type=text id=mmobanpicname[]>
</div></td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
$mobanpicpath="";
$mobanpicnum=0;
if($r[mobanpic])
{
$r[mobanpic]=stripSlashes($r[mobanpic]);
//地址
$j=0;
$pd_record=explode("/r/n",$r[mobanpic]);
for($i=0;$i<count($pd_record);$i++)
{
$j=$i+1;
$pd_field=explode("::::::",$pd_record[$i]);
$mobanpicpath.="<tr>
<td width='7%'><div align=center>".$j."</div></td>
<td width='33%'><div align=center>
<input name=msmallmobanpic[] type=text value='".$pd_field[0]."' size=28>
</div></td>
<td width='30%'><div align=center>
<input name=mbigmobanpic[] type=text value='".$pd_field[1]."' size=28>
</div></td>
<td width='30%'><div align=center>
<input name=mmobanpicname[] type=text value='".$pd_field[2]."'><input type=hidden name=mmobanpicid[] value=".$j."><input type=checkbox name=mdelmobanpicid[] value=".$j.">删
</div></td></tr>";
}
$mobanpicnum=$j;
$mobanpicpath="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$mobanpicpath."</table>";
}
echo $mobanpicpath;
}
?>
</td>
</tr>
<tr>
<td height="25">地址扩展数量: <input name="mobanpicnum" type="hidden" id="mobanpicnum" value="<?=$mobanpicnum?>">
<input name="downmobanpicnum" type="text" value="1" size="6"> <input type="button" name="Submit5" value="输出地址" onclick="javascript:domobanpicadd();"></td>
</tr>
<tr>
<td id=addmobanpicdown></td>
</tr>
</table>
2. 找到e/class/functions.php 在function ReturnAddF
函数中,morepic 流程后插入如下代码 有两个地方需要插入,自行查找
elseif($f=='mobanpic'){
$add_temp = [
'msmallpic' => $add['msmallmobanpic'],
'mbigpic' => $add['mbigmobanpic'],
'mpicname' => $add['mmobanpicname'],
'mdelpicid' => $add['mdelmobanpicid'],
'mpicid' => $add['mmobanpicid'],
'mpicurl_qz'=> $add['mmobanpicurl_qz'],
'msavepic' => $add['msavemobanpic'],
'mcreatespic'=> $add['mcreatesmobanpic'],
'msmallpfile'=> $add['msmallmobanpfile'],
'mbigpfile'=> $add['mbigmobanpfile'],
];
//设置_FIELS
$_FILES['msmallpfile'] = $_FILES['msmallmobanpfile'];
$_FILES['mbigpfile'] = $_FILES['mbigmobanpfile'];
$add = array_merge($add,$add_temp);
$value=ReturnMorepicpath($add['msmallpic'],$add['mbigpic'],$add['mpicname'],$add['mdelpicid'],$add['mpicid'],$add,$add['mpicurl_qz'],1,0,intval($add['fstb']));
}
到此为此就可以插入多图集了,如上面再来一遍可以添加多个图集字段