MAXWO.COM这次教大家为实现每个栏目都有上传栏目缩略图的功能
修改方法如下:(本文中“dede_arctype”为DEDECMS默认数据库表,各位站长根据自己数据库表名修改)
第一步:执行SQL命令为数据库的栏目表结构添加一个字段
alter table `dede_arctype` add `typeimg` char(100) NOT NULL default ”; |
第二步:修改涉及到文件:
dede/catalog_add.php
dede/catalog_edit.php
dede/templets/catalog_add.htm
dede/templets/catalog_edit.htm
1、打开dede/catalog_add.php
查找
$queryTemplate = “INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir, |
将
$queryTemplate = “INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir, |
替换为
$queryTemplate = “INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir,typeimg, |
将
(‘~reid~’,’~topid~’,’~rank~’,’~typename~’,’~typedir~’, |
替换为
(‘~reid~’,’~topid~’,’~rank~’,’~typename~’,’~typedir~’,’~typeimg~’, |
查找
$in_query = “INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir, |
替换为
$in_query = “INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir,typeimg, |
保存dede/catalog_add.php
2、打开dede/catalog_edit.php
查找
$upquery = “UPDATE `#@__arctype` SET |
在typedir=’$typedir’, 其下面增加一行:
`typeimg`=’$typeimg’, |
保存catalog_edit.php
3.开始修改栏目添加模板文件
打开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 height=”26″ style=”padding-left:10px;”>列表命名规则:</td>
<td>
<input name=”namerule2″ type=”text” id=”namerule2″ value=”{typedir}/list_{tid}_{page}.html” class=”pubinputs” style=”width:250px” />
<img src=”images/help.gif” alt=”帮助” width=”16″ height=”16″ border=”0″ style=”cursor:pointer” onClick=”ShowHide(‘helpvar3’)”/></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> <!--增加栏目缩略图--> 保存catalog_add.htm 4.开始修改栏目编辑模板文件
打开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 height=”26″ style=”padding-left:10px;”>列表命名规则:</td>
<td> <input name=”namerule2″ type=”text” id=”namerule2″ value=”<?php echo $myrow[‘namerule2’]?>” size=”40″ class=”iptxt” />
<img src=”images/help.gif” alt=”帮助” width=”16″ height=”16″ border=”0″ style=”cursor:pointer” onClick=”ShowHide(‘helpvar3’)”/></td>
</tr>
在这里下面增加
<!–增加栏目缩略图–>
<tr>
<td width=”90″ height=”81″ style=”padding-left:10px;”>栏目图片:</td></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>
<!–增加栏目缩略图–>
保存catalog_edit.htm
大功告成!!!!
如果想同时在文章内容页调用栏目图片打开,修改\include\arc.archives.class.php
查找
if($this->ChannelUnit->ChannelInfos['issystem']!=-1)
将
$query = “Select arc.*,tp.reid,tp.typedir,ch.addtable from `#@__archives` arc left join #@__arctype tp on tp.id=arc.typeid left join #@__channeltype as ch on arc.channel = ch.id where arc.id=’$aid’ “; $this->Fields = $this->dsql->GetOne($query);
替换为:
$query = “Select arc.*,tp.reid,tp.typedir,tp.typeimg,ch.addtable from `#@__archives` arc left join #@__arctype tp on tp.id=arc.typeid left join #@__channeltype as ch on arc.channel = ch.id where arc.id=’$aid’ “; $this->Fields = $this->dsql->GetOne($query);
最后在需要调用的地方添加
{dede:field.typeimg /}
完美!!MAXWO.COM