DedeCms 欄目增加縮略圖功能的方法
來(lái)源:易賢網(wǎng) 閱讀:1203 次 日期:2014-09-02 15:09:40
溫馨提示:易賢網(wǎng)小編為您整理了“DedeCms 欄目增加縮略圖功能的方法”,方便廣大網(wǎng)友查閱!

此功能添加涉及到以下文件

dede/catalog_add.php

dede/catalog_edit.php

dede/templets/catalog_add.htm

dede/templets/catalog_edit.htm

include/taglib/channel.lib.php

此升級(jí)修改方法,在V5.7,V5.7sp1 測(cè)試通過(guò),其他版本未測(cè)試,原理基本相同,請(qǐng)大家自行測(cè)試是否可行。

首先給 欄目表(`#@__arctype`)增加一個(gè)字段typeimg

alter table `#@__arctype` add `typeimg` varchar(200) NOT NULL default ;

修改catalog_add.php文件

打開(kāi)dede/catalog_add.php

查找$queryTemplate = “insert into `#@__arctype`

(reid,topid,sortrank,typename,typedir,

替換為:

(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,

替換為:

(reid,topid,sortrank,typename,typedir,typeimg,

(‘$reid’,'$topid’,'$sortrank’,'$typename’,'$typedir’,

替換為:

(‘$reid’,'$topid’,'$sortrank’,'$typename’,'$typedir’,'$typeimg’,

保存catalog_add.php

下面修改catalog_edit.php文件

打開(kāi)dede/catalog_edit.php

查找$upquery = “Update `#@__arctype` set

在 typedir=’$typedir’, 其下面增加一行:

`typeimg`=’$typeimg’,

保存catalog_edit.php

開(kāi)始修改欄目添加模板文件

打開(kāi)dede/templets/catalog_add.htm

在最上面找到這個(gè)段

<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>

列表命名規(guī)則:

<tr>

<td height="26" style="padding-left:10px;">列表命名規(guī)則:</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>

在標(biāo)簽下面增加一行:

<!--增加欄目縮略圖-->

<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'/>遠(yuǎn)程<br />(欄目模板里用{dede:field.typeimg /}調(diào)用

</td>

</tr>

</table>

</td>

<td width="150" align="center">

<div id='divpicview' class='divpre'></div>

</td>

</tr>

<!--增加欄目縮略圖-->

保存catalog_add.htm

開(kāi)始修改欄目編輯模板文件

打開(kāi)dede/templets/catalog_edit.htm

在最上面找到這個(gè)段

<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;">列表命名規(guī)則:</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'>

遠(yuǎn)程<br />(欄目模板里用{dede:field.typeimg /}調(diào)用)

</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

至此已經(jīng)修改完成!

欄目圖片的添加或修改圖片時(shí)在 (欄目管理>高級(jí)選項(xiàng))里面就會(huì)自動(dòng)出現(xiàn)欄目圖片添加的選擇,點(diǎn)擊選擇圖片,彈出窗口內(nèi)選擇瀏覽上傳就OK

注意:前臺(tái)欄目標(biāo)簽調(diào)用的時(shí)候,還需要改一個(gè)文件,才能實(shí)現(xiàn)欄目圖片顯示,否則只能通過(guò)sql語(yǔ)句才能顯示圖片。

打開(kāi):include/taglib/channel.lib.php

找到

if($type=='top')

{

$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description

From `#@__arctype` where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row";

}

else if($type=="son")

{

//if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];

if($typeid==0) {

return '';

}

$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description

From `#@__arctype` where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";

}

else if($type=="self")

{

if($reid==0) {

return '';

}

$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description

From `#@__arctype` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row";

}

替換成下面的:

if($type=='top')

{

$sql = "Select id,typename,typeimg,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description

From `#@__arctype` where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row";

}

else if($type=="son")

{

//if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];

if($typeid==0) {

return '';

}

$sql = "Select id,typename,typeimg,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description

From `#@__arctype` where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";

}

else if($type=="self")

{

if($reid==0) {

return '';

}

$sql = "Select id,typename,typeimg,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description

From `#@__arctype` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row";

}

調(diào)用方法:

<img src=”[field:typeimg /]” />

最近有很多網(wǎng)友問(wèn)到修改的方法,現(xiàn)在我把已經(jīng)修改好的后臺(tái)文件分享出來(lái),下載下來(lái)直接覆蓋到后臺(tái)就可以了。http://115.com/file/anqwqyi0

如果想同時(shí)在文章內(nèi)容頁(yè)調(diào)用欄目圖片打開(kāi),修改includearc.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);

更多信息請(qǐng)查看IT技術(shù)專欄

更多信息請(qǐng)查看CMS教程
易賢網(wǎng)手機(jī)網(wǎng)站地址:DedeCms 欄目增加縮略圖功能的方法
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
相關(guān)閱讀CMS教程

2025國(guó)考·省考課程試聽(tīng)報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)