此功能添加涉及到以下文件
dede/catalog_addphp
dede/catalog_editphp
dede/templets/catalog_addhtm
dede/templets/catalog_edithtm
include/taglib/channellibphp
此升级修改方法在VVsp 测试通过其他版本未测试原理基本相同请大家自行测试是否可行
首先给 栏目表(`dede_arctype`)增加一个字段typeimg
alter table `dede_arctype` add `typeimg` varchar() NOT NULL default ;
修改catalog_addphp文件
打开dede/catalog_addphp
查找$queryTemplate = “insert into `dede_arctype`
将
(reidtopidsortranktypenametypedir
替换为
(reidtopidsortranktypenametypedirtypeimg
将
(‘~reid~’~topid~’~rank~’~typename~’~typedir~’
替换为
(‘~reid~’~topid~’~rank~’~typename~’~typedir~’~typeimg~’
查找$in_query = “INSERT INTO `dede_arctype`
将
(reidtopidsortranktypenametypedir
替换为
(reidtopidsortranktypenametypedirtypeimg
将
(‘$reid’$topid’$sortrank’$typename’$typedir’
替换为
(‘$reid’$topid’$sortrank’$typename’$typedir’$typeimg’
保存catalog_addphp
下面修改catalog_editphp文件
打开dede/catalog_editphp
查找$upquery = “Update `dede_arctype` set
在 typedir=’$typedir’ 其下面增加一行
`typeimg`=’$typeimg’
保存catalog_editphp
开始修改栏目添加模板文件
打开dede/templets/catalog_addhtm
在最上面找到这个段
<title>栏目管理</title>
<link href=”css/basecss” rel=”stylesheet” type=”text/css”>
替换为:
<title>栏目管理</title>
<link href=”css/basecss” rel=”stylesheet” type=”text/css”>
<script language=”javascript” src=”/include/js/dedeajaxjs”></script>
<script language=’javascript’ src=”js/mainjs”></script>
<script type=”text/javascript” src=”js/calendar/calendarjs”></script>
列表命名规则
<tr>
<td height="" style="paddingleft:px;">列表命名规则</td>
<td>
<input name="namerule" type="text" id="namerule" value="{typedir}/list_{tid}_{page}html" class="pubinputs" style="width:px" />
<img src="images/helpgif" alt="帮助" width="" height="" border="" style="cursor:pointer" onClick="ShowHide(helpvar)"/></td>
</tr>
在标签下面增加一行
<!增加栏目缩略图>
<tr>
<td width="" style="paddingleft:px;">栏目图片</td>
<td width="">
<table width="%" border="" cellspacing="" cellpadding="">
<tr>
<td height="">
<input name="typeimg" type="text" id="typeimg" style="width:px" />
<input type="button" value="本地上传" style="width:px;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 archives_addphp);" size="" class=np coolbg/></span>
<input type="button" name="Submit" value="选择图片" style="marginleft:px;" onClick="SelectImage(formtypeimgsmall);" class=np coolbg/>
<input type="button" name="Submit" value="裁剪" style="marginleft:px;" onClick="imageCut(typeimg);" class=np coolbg/>
<input type=checkbox class=np name=ddisremote value= id=ddisremote/>远程<br />(栏目模板里用{dede:fieldtypeimg /}调用
</td>
</tr>
</table>
</td>
<td width="" align="center">
<div id=divpicview class=divpre></div>
</td>
</tr>
<!增加栏目缩略图>
保存catalog_addhtm
开始修改栏目编辑模板文件
打开dede/templets/catalog_edithtm
在最上面找到这个段
<title>栏目管理</title>
<link href=”css/basecss” rel=”stylesheet” type=”text/css”>
替换为:
<title>栏目管理</title>
<link href=”css/basecss” rel=”stylesheet” type=”text/css”>
<script language=”javascript” src=”/include/js/dedeajaxjs”></script>
<script language=”javascript” src=”js/mainjs”></script>
<script type=”text/javascript” src=”js/calendar/calendarjs”></script>
查找
<tr>
<td height="" style="paddingleft:px;">列表命名规则</td>
<td> <input name="namerule" type="text" id="namerule" value="<?php echo $myrow[namerule]?>" size="" class="iptxt" />
<img src="images/helpgif" alt="帮助" width="" height="" border="" style="cursor:pointer" onClick="ShowHide(helpvar)"/></td>
</tr>
在其下面增加一行
<!增加栏目缩略图>
<tr>
<td width="" height="" style="paddingleft:px;">栏目图片</td></td>
<td width="">
<input name="typeimg" type="text" id="typeimg" style="width:px" value="<?php echo $myrow[typeimg]?>"><input type="button" name="Submit" value="浏览" style="width:px" onClick="SelectImage(formtypeimg);">
<input type="button" name="Submit" value="裁剪" style="marginleft:px;" onClick="imageCut(typeimg);" class=np coolbg/>
<input type=checkbox class=np name=ddisremote value=>
远程<br />(栏目模板里用{dede:fieldtypeimg /}调用)
</td>
<td align="center">
<img src="<?php if($myrow[typeimg]!="") echo $myrow[typeimg]; else echo "images/pviewgif";?>" width="" height="" id="picview" name="picview">
</td>
</tr>
<!增加栏目缩略图>
保存catalog_edithtm
至此已经修改完成!
栏目图片的添加或修改图片时在 (栏目管理>高级选项)里面就会自动出现栏目图片添加的选择点击选择图片弹出窗口内选择浏览上传就OK
注意前台栏目标签调用的时候还需要改一个文件才能实现栏目图片显示否则只能通过sql语句才能显示图片
打开include/taglib/channellibphp
找到
if($type==top)
{
$sql = "Select idtypenametypedirisdefaultispartdefaultnamenamerulemoresitesiteurlsitepathdescription
From `dede_arctype` where reid= And ishidden<> order by sortrank asc limit $row";
}
else if($type=="son")
{
//if($_sys_globals[typeid]>) $typeid = $_sys_globals[typeid];
if($typeid==) {
return ;
}
$sql = "Select idtypenametypedirisdefaultispartdefaultnamenamerulemoresitesiteurlsitepathdescription
From `dede_arctype` where reid=$typeid And ishidden<> order by sortrank asc limit $row";
}
else if($type=="self")
{
if($reid==) {
return ;
}
$sql = "Select idtypenametypedirisdefaultispartdefaultnamenamerulemoresitesiteurlsitepathdescription
From `dede_arctype` where reid=$reid And ishidden<> order by sortrank asc limit $row";
}
替换成下面的
if($type==top)
{
$sql = "Select idtypenametypeimgtypedirisdefaultispartdefaultnamenamerulemoresitesiteurlsitepathdescription
From `dede_arctype` where reid= And ishidden<> order by sortrank asc limit $row";
}
else if($type=="son")
{
//if($_sys_globals[typeid]>) $typeid = $_sys_globals[typeid];
if($typeid==) {
return ;
}
$sql = "Select idtypenametypeimgtypedirisdefaultispartdefaultnamenamerulemoresitesiteurlsitepathdescription
From `dede_arctype` where reid=$typeid And ishidden<> order by sortrank asc limit $row";
}
else if($type=="self")
{
if($reid==) {
return ;
}
$sql = "Select idtypenametypeimgtypedirisdefaultispartdefaultnamenamerulemoresitesiteurlsitepathdescription
From `dede_arctype` where reid=$reid And ishidden<> order by sortrank asc limit $row";
}
调用方法
<img src=”[field:typeimg /]” />
最近有很多网友问到修改的方法现在我把已经修改好的后台文件分享出来下载下来直接覆盖到后台就可以了
如果想同时在文章内容页调用栏目图片打开修改includearcarchivesclassphp
查找
if($this>ChannelUnit>ChannelInfos[issystem]!=)
将
$query = “Select arc*tpreidtptypedirchaddtable
from `dede_archives` arc
left join dede_arctype tp on tpid=arctypeid
left join dede_channeltype as ch on arcchannel = chid
where arcid=’$aid’ “;
$this>Fields = $this>dsql>GetOne($query);
替换为
$query = “Select arc*tpreidtptypedirtptypeimgchaddtable
from `dede_archives` arc
left join dede_arctype tp on tpid=arctypeid
left join dede_channeltype as ch on arcchannel = chid
where arcid=’$aid’ “;
$this>Fields = $this>dsql>GetOne($query);
保存文件即可
原文地址