转:在织梦dedecms栏目内容中增加栏目图片

1. 首先,给栏目分类表dede_arctype表增加缩略图字段typeimg,用phpMyAdmin或其他数据库管理工具,直接在数据表中添加该字段,或者运行下面的SQL语句:

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

2. 修改页面,在表单中添加相应的字段,涉及到的页面有: 

dede/catalog_add.php 
dede/catalog_edit.php 
dede/templets/catalog_add.htm 
dede/templets/catalog_edit.htm

2.1 打开dede/templets/catalog_add.htm,查找

1 <tr>
2     <td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目名称:</font></td>
3     <td class='bline'><input name="typename" type="text" id="typename" size="30" class="iptxt" /></td>
4 </tr>

在其下面加上如下代码:

1 <tr>
2     <td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目图片:</font></td>
3     <td class='bline'>
4         <input name="typeimg" type="text" style="width:250px" id="typeimg" class="alltxt" value="" />
5         <input type="button" name="set9" value="浏览... "class="coolbg np" style="width:60px" onClick="SelectImage('form1.typeimg','');" />
6     </td>
7 </tr>

并在之间引入如下js:

1 <script language="javascript" src="js/main.js"></script>

2.2 打开dede/catalog_add.php页面,保存上传栏目图片的内容,查找

1 $queryTemplate = "INSERT INTO

1 (reid,topid,sortrank,typename

的后面添加 ,typeimg 字段,再找到

1 ('~reid~','~topid~','~rank~','~typename~',

在其后面添加 ,'~typeimg~' 字段,接着查找

1 $in_query = "INSERT INTO

1 (reid,topid,sortrank,typename

后面同样添加 ,typeimg 字段,并在

1 ('$reid','$topid','$sortrank','$typename'

后面添加 ,'$typeimg' 字段。

2.3 打开dede/templets/catalog_edit.htm页面,查找

1 <tr> 
2     <td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目名称:</font></td>
3     <td class='bline'><input name="typename" type="text" id="typename" size="30" value="<?php echo $myrow['typename']?>" class="iptxt" /></td>
4 </tr>

在其下面添加:

1 <tr>
2     <td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目图片:</font></td>
3     <td class='bline'>
4         <input name="typeimg" type="text" style="width:250px" id="typeimg" class="alltxt" value="<?php echo $myrow['typeimg']?>" />
5         <input type="button" name="set9" value="浏览... "class="coolbg np" style="width:60px" onClick="SelectImage('form1.typeimg','');" />
6     </td>
7 </tr>

并在之间引入下面的js文件

1 <script language='javascript' src="js/main.js"></script>

2.4 打开dede/catalog_edit.php,查找下面的代码(会查询到多条记录,选第一个)

1 $upquery = "UPDATE `#@__arctype` SET

1 typename='$typename',

的后面添加

typeimg='$typeimg',

然后保存。

3. 调用栏目通边 channel 标签调用,所以要更改, 进入/include/taglib/channel.lib.php文件,找到78行,把以下的代码替换默认(添加typeimg字段查询)

 1 if($type=='top')
 2 {
 3 $sql = "SELECT id,typename,typeimg,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typeimg
 4 From `dede_arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line ";
 5 }
 6 else if($type=='son')
 7 {
 8 if($typeid==0) return '';
 9 $sql = "SELECT id,typename,typeimg,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,content,typeimg
10 From `dede_arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit 0, $line ";
11 }
12 else if($type=='self')
13 {
14 if($reid==0) return '';
15 $sql = "SELECT id,typename,typeimg,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typeimg
16 FROM `dede_arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
17 } 

4. 调用栏目通边 type 标签调用,所以要更改, 进入/include/taglib/type.lib.php文件,找到42行,把以下的代码替换默认(添加typeimg字段查询)

1 $row = $dsql->GetOne("SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath 
2                           FROM `#@__arctype` WHERE id='$typeid' ");

5. 调用

{dede:channel typeid="1"} 
<li> <img src='[field:typeimg/]' /></li> 
{/dede:channel}

{dede:type typeid="1"} 
<li><img src='[field:typeimg/]' /></li> 
{/dede:type}

转载自:https://blog.csdn.net/jklgfgdsr/article/details/80596880

增加了type标签

猜你喜欢

转载自www.cnblogs.com/fudanchencds/p/11301967.html