请选择 进入手机版 | 继续访问电脑版

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

[复制链接]
查看2062 | 回复0 | 2020-11-3 14:25 | 显示全部楼层 |阅读模式
网站每个栏目都有不同的banner大图,为了方便客户可以直接在后台栏目处添加和更换这个栏目图片,我们需要给dedecms二次开发,增加栏目图片上传选项。
织梦栏目添加banner大图上传选项

1.先给数据库中的dede_arctype表增加一个字段
后台 - 系统 - 系统设置 - SQL命令行工具
ALTER TABLE `dede_arctype` ADD `typebigpic` CHAR( 255 ) NOT NULL DEFAULT '';

2.打开 \dede\templets\catalog_add.htm 搜索
name="typename"
在它的</tr>下面加入
  1. <script language='javascript' src="js/main.js"></script>
  2. <tr id="pictable">
  3. <td height="24" colspan="6">
  4. <table border="0" cellspacing="0" cellpadding="0">
  5. <tr>
  6. <td width="158">  图片地址:</td>
  7. <td width="560">
  8. <table width="100%" border="0" cellspacing="1" cellpadding="1">
  9. <tr>
  10. <td height="30">
  11. <input name="typebigpic" type="text" id="picname" style="width:220px" value="" />
  12. <input type="button" name="Submit2" value="站内选择" style="margin-left:8px;" onClick="SelectImage('form1.picname','');" class='np coolbg'/>
  13. </td>
  14. </tr>
  15. </table>
  16. </td>
  17. <td width="270">
  18. <style>
  19. .divpre,.divpre img{height:50px;}
  20. </style>
  21. <img src="images/pview.gif" width="100" height="50" id="picview" name="picview">
  22. </td>
  23. </tr>
  24. </table>
  25. </td>
  26. </tr>
复制代码
3.打开 \dede\templets\catalog_edit.htm 搜索
name="typename"
在它的</tr>下面加入
  1. <script language='javascript' src="js/main.js"></script>
  2. <tr id="pictable">
  3. <td height="24" colspan="6">
  4. <table border="0" cellspacing="0" cellpadding="0">
  5. <tr>
  6. <td width="158">  图片地址:</td>
  7. <td width="560">
  8. <table width="100%" border="0" cellspacing="1" cellpadding="1">
  9. <tr>
  10. <td height="30">
  11. <input name="typebigpic" type="text" id="picname" style="width:220px" value="<?php echo $myrow['typebigpic']?>" />
  12. <input type="button" name="Submit2" value="站内选择" style="margin-left:8px;" onClick="SelectImage('form1.picname','');" class='np coolbg'/>
  13. </td>
  14. </tr>
  15. </table>
  16. </td>
  17. <td width="270">
  18. <style>
  19. .divpre,.divpre img{height:50px;}
  20. </style>
  21. <img src="<?php if($myrow['typebigpic']!="") echo $myrow['typebigpic']; else echo "images/pview.gif";?>" width="100" height="50" id="picview" name="picview">
  22. </td>
  23. </tr>
  24. </table>
  25. </td>
  26. </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,typebigpic
继续搜索
VALUES('$reid','$topid','$sortrank','$typename'
改成
VALUES('$reid','$topid','$sortrank','$typename','$typebigpic'

5.打开 \dede\catalog_edit.php 搜索
`smalltypes`='$smalltypes'
改成
`smalltypes`='$smalltypes',`typebigpic`='$typebigpic'

6.打开 \include\taglib\channelartlist.lib.php 搜索
typedir
改成
typedir,typebigpic
7.打开 \include\taglib\channel.lib.php 搜索
typedir
改成
typedir,typebigpic
注意:这个文件有4处都需要改
8.打开 \include\taglib\type.lib.php 搜索
typedir
改成
typedir,typebigpic
9.\include\arc.listview.class.php 搜索
//设置环境变量
在它下面添加
$this->Fields['typebigpic'] = $this->TypeLink->TypeInfos['typebigpic'];

后台栏目效果

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

织梦增加栏目缩略图、添加栏目图片功能的方法
前台模板中调用标签
  1. {dede:channelartlist}{dede:field.typebigpic/}{/dede:channelartlist}

  2. {dede:channel}[field:typebigpic/]{/dede:channel}

  3. {dede:type}[field:typebigpic/]{/dede:type}
复制代码
栏目列表页单独调用
{dede:field.typebigpic/}

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
1
贡献
387
丢币
38902
主题
4607
回帖
116
注册时间
2018-9-25
最后登录
2024-3-18