有时候因为网站功能需求,我们需要为织梦程序的栏目页添加缩略图功能,这里有一个栏目添加缩略图的方法,供大家参考。

涉及到文件如下(请务必提前备份):

dede/catalog_add.php 

dede/catalog_edit.php

dede/templets/catalog_add.htm

dede/templets/catalog_edit.htm

打开文件夹templets这个目录,在里面新建一个文件夹typeimg,用于独立存放栏目缩略图。

新加字段 typeimg (用于存放缩略图路径)

后台执行SQL(前缀默认为dede_ 具体前缀根据自己网站修改):


alter table `dede_arctype` add `typeimg` char(100) NOT NULL default '';

打开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~',

打开dede/catalog_edit.php

查找:


$upquery = "Update `dede_arctype` set

在其下面新加一行


`typeimg`='$typeimg',

打开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">栏目图片:</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="SelectTemplets('form1.typeimg&activepath=%2Ftemplets%2Ftypeimg&img=yes');" />
  (栏目模板里用{dede:field.typeimg /}调用)
  </td>
</tr>

打开dede/templets/catalog_edit.htm 查找


<tr>
  <td height="26">列表命名规则:</td>
  <td> <input name="namerule2" type="text" id="namerule2" value="<?php echo $myrow['namerule2']?>" size="40" class="iptxt" />
  <img src="img/help.gif" alt="帮助" width="16" height="16" border="0" style="cursor:pointer" onClick="ShowHide('helpvar3')"/></td><
</tr>

在其下面新增以下内容:


<tr>
  <td height="65">栏目图片:</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="SelectImages('form1.typeimg&activepath=%2Ftemplets%2Ftypeimg&img=yes');" />
  (栏目模板里用{dede:field.typeimg /}调用)
  </td>
</tr>

完成!

添加或修改图片时在 栏目管理》高级选项上传即可。

如果想同时在文章内容页调用的话,打开\include\arc.archives.class.php 查找


if($this->ChannelUnit->ChannelInfos['issystem']!=-1)


$query = "Select arc.*,tp.reid,tp.typedir,ch.addtable
	from `dede_archives` arc
	left join dede_arctype tp on tp.id=arc.typeid
	left join dede_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 `dede_archives` arc
	left join dede_arctype tp on tp.id=arc.typeid
	left join dede_channeltype as ch on arc.channel = ch.id
	where arc.id='$aid' ";
	$this->Fields = $this->dsql->GetOne($query);

OK,给织梦给栏目增加缩略图的方法就介绍到这了,有需要的朋友可以自行参考修改调整。

(adsbygoogle = window.adsbygoogle || []).push({});