程序员人生 网站导航

PHPCMS 2008 SP4多个多图字段问题的解决方法

栏目:DedeCMS时间:2014-01-08 01:54:49

1.修改include/fields/images/form.inc.php

function images($field, $value, $fieldinfo)
{
global $attachment;
extract($fieldinfo);
$data = '';
$data .= "<div id='FilePreview' style='Z-INDEX: 1000; LEFT: 0px; WIDTH: 10px; POSITION: absolute; TOP: 0px; HEIGHT: 10px; display: none;'></div>";
if(!$value)
{
$value = $defaultvalue;
}
else
{
$data .= "<div id='file_uploaded'>";
$attachments = $attachment->listinfo("`contentid`=$this->contentid AND `field`='$field'", '`aid`,`filename`,`filepath`,`description`,`listorder`,`isthumb`');
foreach($attachments as $k=>$v)
{
$aid = $v['aid'];
$url = $v['isthumb'] ? $attachment->get_thumb($v['filepath']) : $v['filepath'];
$data .= "<div id='file_uploaded_$aid'><span style='width:30px'><input type='checkbox' name='{$field}_delete[]' value='$aid' title='删除'></span><span style='width:40px'><input type='text' name='{$field}_listorder[$aid]' value='$v[listorder]' size='3' title='排序'></span><span style='width:60px'><input type='text' name='{$field}_description[$aid]' value='$v[description]' size='20' title='修改图片说明'></span> <a href='###' onMouseOut='javascript:FilePreview("$url", 0);' onMouseOver='javascript:FilePreview("$url", 1);'>$v[filename] ".($v['description'] ? '('.$v['description'].')' : '')."</a></div>";
}
$data .= "</div>";
}
$addmorepic = '';
if(defined('IN_ADMIN')) $addmorepic = '<input type="button" onclick="AddMorePic('addmore_'.$field.'');" value="批量添加">';
$data .= "<div id='addmore_$field'></div>";
$data .= '<input type="hidden" name="info['.$field.']" value="'.$value.'"/>';
$data .= '<div id="file_div_'.$field.'">';
$data .= '<div id="file_1"><input type="file" name="'.$field.'[1]" size="20" onchange="javascript:AddInputFile(''.$field.'', ''.$field.'')"> <input type="text" name="'.$field.'_description[1]" size="20" title="名称"> <input type="button" value="删除" name="Del" onClick="DelInputFile(1, 1);">
'.$addmorepic.'</div>';
$data .= '</div>';
$_SESSION['field_images'] = 1;
return $data;
}

2.修改images/js/common.js

查找:

var FileNum = 1; 一直到 function FilePreview(Url, IsShow)的上面。

替换为代码:

var FileNum = 1;
function AddInputFile(Field, fileName)
{
FileNum++;
var fileTag = "<div id='file_"+FileNum+"'><input type='file' name='"+Field+"["+FileNum+"]' size='20' onchange='javascript:AddInputFile(""+Field+"", ""+Field+"")'> <input type='text' name='"+Field+"_description["+FileNum+"]' size='20' title='名称'> <input type='button' value='删除' name='Del' onClick='DelInputFile("+FileNum+", 1);'></div>";
var fileObj = document.createElement("div");
fileObj.id = 'file_'+FileNum;
fileObj.innerHTML = fileTag;
if(arguments.length == 1)
{
document.getElementById("file_div").appendChild(fileObj);
}
else
{
document.getElementById("file_div_"+fileName).appendChild(fileObj);
}
}

function DelInputFile(FileNum, fileName)
{
var DelObj = document.getElementById("file_"+FileNum);
if(arguments.length == 1)
{
document.getElementById("file_div").removeChild(DelObj);
}
else
{
document.getElementById("file_div_"+Field).removeChild(DelObj);
}
}

------分隔线----------------------------
------分隔线----------------------------

最新技术推荐