1. 首页
  2. 帝国cms

帝国cms自定义模型修改添加多个图集字段

因为 最近做站一个模型里有两个字段均为图集形式的,帝国虽然有图集模块,但不能实现多个字段是图集,所以稍微改造了一下 下面效果图

效果图:

1.首先按正常步骤,在对应模型里加上相应字段 这里我习惯遵从原来图集系统起名 mobanpic, 管理字段-》修改 -》输入表单替换html代码 将我下面这段代码复制进去

注意下面代码中 把”moban”字段替换成自己对应的名称,我这里字段名为mobanpic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<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+"</p>
<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>
<p>"
;
}
document.getElementById("addmobanpicdown").innerHTML="</p>
<table width='100%' border=0 cellspacing=1 cellpadding=3>"
+str+"</table>
<p>"
;
}
</script>

";
}
$mobanpicnum=$j;
$mobanpicpath="

<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td height="25">图片地址前缀:
<input id="mmobanpicurl_qz" name="mmobanpicurl_qz" type="text" />
<input name="msavemobanpic" type="checkbox" value="1" />远程保存 <input name="mcreatesmobanpic" type="checkbox" value="1" />生成缩图
<span id="setmcreatesmobanpic" style="display: none;"><input name="mcreatesmobanpicwidth" size="4" type="text" value="&lt;?=$public_r[spicwidth]?&gt;" />*<input name="mcreatespicheight" size="4" type="text" value="&lt;?=$public_r[spicheight]?&gt;" />(*)</span>
<!--?php if(TranmoreIsOpen()) { ?-->
<input name="Submit" type="button" value="多选上传" />
<!--?php } ?--></td>
</tr>
<tr>
<td>
<table border="0" width="100%" cellspacing="1" cellpadding="3" align="center">
<tbody>
<tr bgcolor="#DBEAF5">
<td width="7%">
<div align="center">编号</div></td>
<td width="33%">
<div align="center">缩图 <span style="color: #666666;">(双击选择)</span></div></td>
<td width="30%">
<div align="center">大图 <span style="color: #666666;">(双击选择)</span></div></td>
<td width="30%">
<div align="center">图片说明</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td id="defmobanpicid"><!--?php if($ecmsfirstpost==1) { ?--> $mobanpicnum=3;for($mppathi=1;$mppathi&lt;=$mobanpicnum;$mppathi++) { ?&gt;
<table border="0" width="100%" cellspacing="1" cellpadding="3" align="center"><!--?php &lt;br ?-->
<tbody>
<tr>
<td width="7%">
<div align="center"><!--?=$mppathi? &gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width='33%'&gt;
&lt;div align=center&gt;
           &lt;input name=msmallmobanpic[] type=text id='msmallmobanpic&lt;?=$mppathi?-->' size=28 ondblclick="SpOpenChFile(1,'msmallmobanpic<!--?=$mppathi? &gt;');"&gt;&lt;br ?-->
<input name="msmallmobanpfile[]" size="15" type="file" /></div></td>
<td width="30%">
<div align="center"><input id="mbigmobanpic&lt;?=$mppathi?&gt;" name="mbigmobanpic[]" size="28" type="text" />

<input name="mbigmobanpfile[]" size="15" type="file" /></div></td>
<td width="30%">
<div align="center"><input id="mmobanpicname&lt;?=$mppathi?&gt;" name="mmobanpicname[]" type="text" /></div></td>
</tr>
<!--?php } ?--></tbody>
</table>
<!--?php &lt;br ?--> }
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&lt;count($pd_record);$i++)
{
$j=$i+1;
$pd_field=explode("::::::",$pd_record[$i]);
$mobanpicpath.="</td>
<td width="
7%">
<div align="
center">".$j."</div></td>
<td width="
33%">
<div align="
center"><input id="msmallmobanpic&quot;.$j.&quot;" name="msmallmobanpic[]" size="28" type="text" value="&quot;.$pd_field[0].&quot;" />

<input name="
msmallmobanpfile[]" size="15" type="file" /></div></td>
<td width="
30%">
<div align="
center"><input id="mbigmobanpic&quot;.$j.&quot;" name="mbigmobanpic[]" size="28" type="text" value="&quot;.$pd_field[1].&quot;" />

<input name="
mbigmobanpfile[]" size="15" type="file" /></div></td>
<td width="
30%">
<div align="
center"><input name="mmobanpicname[]" type="text" value="&quot;.$pd_field[2].&quot;" /><input name="mmobanpicid[]" type="hidden" value=".$j." /><input name="mdelmobanpicid[]" type="checkbox" value=".$j." />删</div></td>
</tr>
</tbody>
</table>
"
.$mobanpicpath."

"
;
}
echo $mobanpicpath;
}
?&gt;

地址扩展数量:

1
2
<input id="mobanpicnum" name="mobanpicnum" type="hidden" value="&lt;?=$mobanpicnum?&gt;" />
<input name="downmobanpicnum" size="6" type="text" value="1" /> <input name="Submit5" type="button" value="输出地址" />

将下面代码复制进 投稿表单替换html代码 和上面的处理方法一样

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<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+"</p>
<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>
<p>"
;
}
document.getElementById("addmobanpicdown").innerHTML="</p>
<table width='100%' border=0 cellspacing=1 cellpadding=3>"
+str+"</table>
<p>"
;
}
</script>

";
}
$mobanpicnum=$j;
$mobanpicpath="

<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td height="25">图片地址前缀:
<input id="mmobanpicurl_qz" name="mmobanpicurl_qz" size="32" type="text" /></td>
</tr>
<tr>
<td>
<table border="0" width="100%" cellspacing="1" cellpadding="3" align="center">
<tbody>
<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>
</tbody>
</table>
</td>
</tr>
<tr>
<td id="defmobanpicid"><!--?php if($ecmsfirstpost==1) { ?--> $mobanpicnum=3;for($mppathi=1;$mppathi&lt;=$mobanpicnum;$mppathi++) { ?&gt;
<table border="0" width="100%" cellspacing="1" cellpadding="3" align="center"><!--?php &lt;br ?-->
<tbody>
<tr>
<td width="7%">
<div align="center"><!--?=$mppathi? &gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td width='33%'&gt;
&lt;div align=center&gt;
           &lt;input name=msmallmobanpic[] type=text id=msmallmobanpic[] size=28&gt;
           &lt;/div&gt;
&lt;/td&gt;
&lt;td width='30%'&gt;
&lt;div align=center&gt;
           &lt;input name=mbigmobanpic[] type=text id=mbigmobanpic[] size=28&gt;
           &lt;/div&gt;
&lt;/td&gt;
&lt;td width='30%'&gt;
&lt;div align=center&gt;
           &lt;input name=mmobanpicname[] type=text id=mmobanpicname[]&gt;
           &lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;p&gt;      &lt;?php } ?--></div></td>
</tr>
</tbody>
</table>
<!--?php &lt;br ?--> }
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&lt;count($pd_record);$i++)
{
$j=$i+1;
$pd_field=explode("::::::",$pd_record[$i]);
$mobanpicpath.="</td>
<td width="
7%">
<div align="
center">".$j."</div></td>
<td width="
33%">
<div align="
center"><input name="msmallmobanpic[]" size="28" type="text" value="&quot;.$pd_field[0].&quot;" /></div></td>
<td width="
30%">
<div align="
center"><input name="mbigmobanpic[]" size="28" type="text" value="&quot;.$pd_field[1].&quot;" /></div></td>
<td width="
30%">
<div align="
center"><input name="mmobanpicname[]" type="text" value="&quot;.$pd_field[2].&quot;" /><input name="mmobanpicid[]" type="hidden" value=".$j." /><input name="mdelmobanpicid[]" type="checkbox" value=".$j." />删</div></td>
</tr>
</tbody>
</table>
"
.$mobanpicpath."

"
;
}
echo $mobanpicpath;
}
?&gt;

地址扩展数量:

1
2
<input id="mobanpicnum" name="mobanpicnum" type="hidden" value="&lt;?=$mobanpicnum?&gt;" />
<input name="downmobanpicnum" size="6" type="text" value="1" /> <input name="Submit5" type="button" value="输出地址" />

2. 找到e\class\functions.php 在function ReturnAddF

函数中,morepic 流程后插入如下代码 有两个地方需要插入,自行查找

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
elseif($f=='mobanpic'){
$add_temp = [
'msmallpic' =&gt; $add['msmallmobanpic'],
'mbigpic' =&gt; $add['mbigmobanpic'],
'mpicname' =&gt; $add['mmobanpicname'],
'mdelpicid' =&gt; $add['mdelmobanpicid'],
'mpicid' =&gt; $add['mmobanpicid'],
'mpicurl_qz'=&gt; $add['mmobanpicurl_qz'],
'msavepic' =&gt; $add['msavemobanpic'],
'mcreatespic'=&gt; $add['mcreatesmobanpic'],
'msmallpfile'=&gt; $add['msmallmobanpfile'],
'mbigpfile'=&gt; $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']));
}

到此为此就可以插入多图集了,如上面再来一遍可以添加多个图集字段

原创文章,作者:懒咪WP,如若转载,请注明出处:https://www.lanmit.com/2425.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据