织梦园模板网提供云优cms模板,pbootcms模板,Wordpress主题模板等各类企业新闻资讯网站模板下载服务。织梦园网站模板交流群
用户名:
密码:
注册
注册后享受折扣价

织梦栏目添加图片图片缩略图的解决方法

织梦园模板 / 2019-03-04 / 收藏

网站每个栏目都有不同的banner大图,为了方便客户可以直接在后台栏目处添加和更换这个栏目图片,我们需要给dedecms二次开发,增加栏目图片上传选项。

织梦栏目添加banner大图上传选项

1.先给数据库中的dede_arctype表增加一个字段

后台 - 系统 - 系统设置 - SQL命令行工具

ALTER TABLE `dede_arctype` ADD `typeimg` CHAR( 255 ) NOT NULL DEFAULT '';

2.打开 \dede\templets\catalog_add.htm

在上面找到这段代码

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

在它的下面加入

<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'/>
                    远程<br />
                    (栏目模板里用{dede:field.typeimg /}调用 </td>
                </tr>
              </table></td>
            <td width="150" align="center"><div id='divpicview' class='divpre'></div></td>
          </tr>


3.打开 \dede\templets\catalog_edit.htm

上面找到这段代码

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

在其下面加入

<tr>
          <td width="90" height="81" style="padding-left:10px;">栏目图片:</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'>
            远程<br />
            (栏目模板里用{dede:field.typeimg /}调用) </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>

4.打开 \dede\catalog_add.php 搜索

$in_query = "INSERT INTO `dede_arctype`(reid,topid,sortrank,typename

改成

$in_query = "INSERT INTO `dede_arctype`(reid,topid,sortrank,typename,typeimg

继续搜索

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

改成

VALUES('$reid','$topid','$sortrank','$typename','$typeimg'

5.打开 \dede\catalog_edit.php 搜索

`smalltypes`='$smalltypes'

改成

`smalltypes`='$smalltypes',`typeimg`='$typeimg'

6.打开 \include\taglib\channelartlist.lib.php 搜索

typedir

改成

typedir,typeimg

7.打开 \include\taglib\channel.lib.php 搜索

typedir

改成

typedir,typeimg

注意:这个文件有4处都需要改

8.打开 \include\taglib\type.lib.php 搜索

typedir

改成

typedir,typeimg

9.\include\arc.listview.class.php 搜索

//设置环境变量

在它下面添加

$this->Fields['typeimg'] = $this->TypeLink->TypeInfos['typeimg'];

 

后台栏目效果

织梦dedecms增加栏目缩略图、栏目图片功能的方法

前台模板中调用标签
{dede:channelartlist}{dede:field.typeimg/}{/dede:channelartlist}

{dede:channel}[field:typeimg/]{/dede:channel}

{dede:type}[field:typeimg/]{/dede:type}

栏目列表页单独调用

{dede:field.typeimg/}

相关织梦技巧

收缩