有些网站为了建站的需要,每个栏目调用对应栏目的图片作为标识,为了方便客户可以直接在后台栏目处添加和更换这个栏目图片,我们需要给dedecms二次开发,增加栏目图片上传选项。
具体步骤如下
1.先给数据库中的dede_arctype表增加一个字段
后台 - 系统 - 系统设置 - SQL命令行工具
alter table `dede_arctype` add `typeimg` char(100) NOT NULL default '';
|
2.打开 dede/templets/catalog_add.htm
在最上面找到这段代码
<title>栏目管理</title>
<link href="css/base.css" rel="stylesheet" type="text/css">
|
替换为:
<title>栏目管理</title>
<link href="css/base.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../include/js/dedeajax2.js"></script>
<script language='javascript' src="js/main.js"></script>
<script type="text/javascript" src="js/calendar/calendar.js"></script>
|
查找
<tr>
<td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目名称:</font></td>
<td class='bline'><input name="typename" type="text" id="typename" size="30" class="iptxt" /></td>
</tr>
|
在它的下面加入
<tr>
<td width="90" style="padding-left:10px;">栏目图片:</td>
<td width="560"><table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td height="30"><input name="typeimg" type="text" id="typeimg" style="width:240px" />
<input type="button" value="本地上传" style="width:70px;cursor:pointer;display:none" />
<iframe name='uplitpicfra' id='uplitpicfra' src='' style='display:none'></iframe>
<span class="litpic_span">
<input name="litpic" type="file" id="litpic" onChange="SeePicNew(this, 'divpicview', 'uplitpicfra', 165, 'archives_add.php');" size="1" class='np coolbg'/>
</span>
<input type="button" name="Submit2" value="选择图片" style="margin-left:8px;" onClick="SelectImage('form1.typeimg','small');" class='np coolbg'/>
<input type="button" name="Submit2" value="裁剪" style="margin-left:8px;" onClick="imageCut('typeimg');" class='np coolbg'/>
<input type='checkbox' class='np' name='ddisremote' value='1' id='ddisremote'/>
远程<br />
(栏目模板里用{dede:field.typeimg /}调用 </td>
</tr>
</table></td>
<td width="150" align="center"><div id='divpicview' class='divpre'></div></td>
</tr>
|
3.打开 dede/templets/catalog_edit.htm
在最上面找到这段代码
<title>栏目管理</title>
<link href="css/base.css" rel="stylesheet" type="text/css">
|
替换为:
<title>栏目管理</title>
<link href="css/base.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../include/js/dedeajax2.js"></script>
<script language="javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/calendar/calendar.js"></script>
|
查找
<tr>
<td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目名称:</font></td>
<td class='bline'><input name="typename" type="text" id="typename" size="30" value="<?php echo $myrow['typename']?>" class="iptxt" /></td>
</tr>
|
在它的下面加入
<tr>
<td width="90" height="81" style="padding-left:10px;">栏目图片:</td>
<td width="500"><input name="typeimg" type="text" id="typeimg" style="width:300px" value="<?php echo $myrow['typeimg']?>">
<input type="button" name="Submit" value="浏览..." style="width:70px" onClick="SelectImage('form1.typeimg','');">
<input type="button" name="Submit2" value="裁剪" style="margin-left:8px;" onClick="imageCut('typeimg');" class='np coolbg'/>
<input type='checkbox' class='np' name='ddisremote' value='1'>
远程<br />
(栏目模板里用{dede:field.typeimg /}调用) </td>
<td align="center"><img src="<?php if($myrow['typeimg']!="") echo $myrow['typeimg']; else echo "images/pview.gif";?>" width="150" height="100" id="picview" name="picview"></td>
</tr>
|
4.打开 dede/catalog_add.php 搜索
$in_query = "INSERT INTO `dede_arctype`(reid,topid,sortrank,typename
|
改成
$in_query = "INSERT INTO `dede_arctype`(reid,topid,sortrank,typename,typeimg
|
继续搜索
VALUES('$reid','$topid','$sortrank','$typename'
|
改成
VALUES('$reid','$topid','$sortrank','$typename','$typeimg'
|
5.打开 dede/catalog_edit.php 搜索
`smalltypes`='$smalltypes'
|
改成
`smalltypes`='$smalltypes',`typeimg`='$typeimg'
|
6.打开 include/taglib/channelartlist.lib.php 搜索
改成
7.打开 include/taglib/channel.lib.php 搜索
改成
注意:这个文件有4处都需要改
8.打开 include/taglib/type.lib.php 搜索
改成
9.include/arc.listview.class.php 搜索
在它下面添加
$this->Fields['typeimg'] = $this->TypeLink->TypeInfos['typeimg'];
|
后台栏目效果
前台模板中调用标签
{dede:channelartlist}{dede:field.typeimg/}{/dede:channelartlist}
{dede:channel}[field:typeimg/]{/dede:channel}
{dede:type}[field:typeimg/]{/dede:type}
|
栏目列表页单独调用
(责任编辑:admin) |