

我们用织梦dedecms制作企业网站时,点击进入每个栏目时,都会有“关于我们”,“新闻中心”,“产品展示”等提示性的图片,
单独调用这些图片比较麻烦,我们可以修改程序,实现每个栏目都有上传栏目缩略图的功能,就方便多了。
修改方法如下:第一步:执行SQL命令为数据库的栏目表结构添加一个字段alter table `dede_arctype` add `typeimg` char(100) NOT NULL default '';第二步:修改涉及到文件:dede/catalog_add.phpdede/catalog_edit.phpdede/templets/catalog_add.htmdede/templets/catalog_edit.htm1、打开dede/catalog_add.php查找$queryTemplate = "insert into `dede_arctype`将(reid,topid,sortrank,typename,typedir,替换为(reid,topid,sortrank,typename,typedir,typeimg,将('~reid~','~topid~','~rank~','~typename~','~typedir~',替换为('~reid~','~topid~','~rank~','~typename~','~typedir~','~typeimg~',2、打开dede/catalog_edit.php查找$upquery = "Update `dede_arctype` set在其下面新加一行`typeimg`='$typeimg',3、打开dede/templets/catalog_add.htm查找
<tr> <td height="26">列表命名规则:</td> <td> <input name="namerule2" type="text" id="namerule2" value="{typedir}/list_{tid}_{page}.html" class="pubinputs" style="width:250px" /> <img src="img/help.gif" alt="帮助" width="16" height="16" border="0" style="cursor:pointer" onClick="ShowHide('helpvar3')"/></td> </tr> <tr> <td height="65" style="padding-left:10px;">栏目图片:</td> <td> <input name="typeimg" type="text" style="width:250px" id="typeimg" class="alltxt" value="" /> <input type="button" name="set9" value="浏览... "class="coolbg np" style="width:60px" onClick="SelectImage('form1.typeimg','');" /> </td> </tr><script language='javascript' src="js/main.js"></script>4、打开dede/templets/catalog_edit.htm在刚前面的位置加入:
<tr> <td height="65" style="padding-left:10px;">栏目图片:</td> <td> <input name="typeimg" type="text" style="width:250px" id="typeimg" class="alltxt" value="<?php echo $myrow['typeimg']?>" /> <input type="button" name="set9" value="浏览... "class="coolbg np" style="width:60px" onClick="SelectImage('form1.typeimg','');" /> </td> </tr>{dede:channel type='top' row='13'} <li><a href='[field:typeurl/]' [field:rel/]>[field:typeimg/]</a></li> {/dede:channel}在这里面加上[field:typeimg]是调不出来的,栏目缩略图就是通过循环出来的,而循环不出来则意义不大,所以改成了如下:{dede:sql sql="SELECT typename,typedir,typeimg FROM dede_arctype"} <li><a href="[field:typedir/]">[field:typeimg/]</a></li>{/dede:sql}这样就顺利的调出来了,当然如果你要调用子ID的话,只要加上相应的条件ID调用就可以了。添加或修改图片时在《栏目管理》高级选项如果想同时在文章内容页调用打开\include\arc.archives.class.php查找if($this->ChannelUnit->ChannelInfos['issystem']!=-1)将
$query = "Select arc.*,tp.reid,tp.typedir,ch.addtable from `ant_archives` arc left join ant_arctype tp on tp.id=arc.typeid left join ant_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 `ant_archives` arc left join ant_arctype tp on tp.id=arc.typeid left join ant_channeltype as ch on arc.channel = ch.id where arc.id='$aid' "; $this->Fields = $this->dsql->GetOne($query);即可。需要这个功能的朋友,去试试吧。