织梦dedecms5.7栏目添加缩略图带裁剪功能

第一步:

新加字段 typeimg
后台执行SQL:
alter table dede_arctype add typeimg char(100) NOT NULL default '';
PS:dede是安装程序时候的表前缀,根据你自己的情况修改

涉及到文件:

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

打开dede/catalog_add.php

查找$queryTemplate = "insert into cn_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


(reid,topid,sortrank,typename,typedir,
替换为
(reid,topid,sortrank,typename,typedir,typeimg,


(reid,topid,sortrank,typename,typedir,
替换为
(reid,topid,sortrank,typename,typedir,typeimg,


('$reid','$topid','$sortrank','$typename','$typedir',
替换为
('$reid','$topid','$sortrank','$typename','$typedir','$typeimg',

打开dede/catalog_edit.php
查找
$upquery = "Update #@__arctype set

在其下面新加一行
typeimg='$typeimg',

打开dede/templets/catalog_add.htm
查找

<tr>
<td height="65" style="padding-left:10px;">SEO标题:</td>
<td>
<input name="seotitle" type="text" style="width:250px" id="seotitle" class="alltxt" value="" />
(栏目模板里用{dede:field.seotitle /}调用)
</td>
</tr>

下加入以下内容:

<tr>
<td height="65" style="padding-left:10px;">栏 目 图:</td>
<td class='bline'>
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="600"><table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td height="30">
<input name="typeimg" type="text" id="picname" style="width:240px" />
<input type="button" value="本地上传" style="width:70px;cursor:pointer;" />
<iframe name='uplitpicfra' id='uplitpicfra' src='http://blog.163.com/pepsl@126/blog/' style='display:none'></iframe>
<span class="litpic_span"><input name="litpic" type="file" id="litpic" onChange="SeePicNew(this, 'divpicview', 'uplitpicfra', 165, 'catalog_add.PHP');" size="1" value="" class='np coolbg'/></span>
<input type="button" name="Submit2" value="站内选择" style="margin-left:8px;" onClick="SelectImage('form1.picname','small');" class='np coolbg'/>
<input type="button" name="Submit2" value="裁剪" style="margin-left:8px;" onClick="imageCut('picname');" class='np coolbg'/>
<input type='checkbox' class='np' name='ddisremote' value='1' id='ddisremote'/>远程</td>
</td>
</tr>
</table></td>
<td width="150" align="center"><div id="divpicview" name="divpicview"></div></td>
</tr>
</table>
</td>
</tr>

并在文件的head增加以下内容
<script language='javascript' src="js/main.js"></script>

打开dede/templets/catalog_edit.htm
在刚前面的位置加入:

<tr>
<td height="65" style="padding-left:10px;">栏 目 图:</td>
<td class='bline'>
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="600"><table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td height="30">
<input name="typeimg" type="text" id="picname" value="<?php echo $myrow['typeimg']?>" style="width:240px" />
<input type="button" value="本地上传" style="width:70px;cursor:pointer;" />
<iframe name='uplitpicfra' id='uplitpicfra' src='http://blog.163.com/pepsl@126/blog/' style='display:none'></iframe>
<span class="litpic_span"><input name="litpic" type="file" id="litpic" size="1" onChange="SeePicNew(this, 'divpicview', 'uplitpicfra', 165, 'catalog_add.php');" class='np coolbg'/></span>
<input type="button" name="Submit2" value="站内选择" style="margin-left:8px;" onClick="SelectImage('form1.picname','small');" class='np coolbg'/>
<input type="button" name="Submit2" value="裁剪" style="margin-left:8px;" onClick="imageCut('picname');" class='np coolbg'/>
<input type='checkbox' class='np' name='ddisremote' value='1' id='ddisremote'/>远程
</td>
</tr>
</table></td>
<td align="left">
<img src="http://blog.163.com/pepsl@126/blog/<?php if($myrow["typeimg"]!="") echo $myrow["typeimg"]; else echo "images/pview.gif";?>" width="150" height="100" id="picview" name="picview">
</td>
</tr>
</table>
</td>
</tr>

说明:下面这句会调用出已添加的路片路径。
<?php echo $myrow['typeimg']?>

并在文件的head增加以下内容
<script language='javascript' src="http://blog.163.com/pepsl@126/blog/js/main.js"></script&gt;

我试了一下在模版里用:{dede:field.typeimg /} 是调不出数据的,所以我改成了SQL调用。
原来是这样的:

{dede:channel type='top' row='13'}
<li><a href='[field:typeurl/]' [field:rel/]>[field:typeimg/]</a></li>
{/dede:channel}

在这里面加上[field:typeimg] 是调不出来的,我个人认为栏目缩略图就是通过循环出来的,而循环不出来则意义不大,所以改成了如下:

  {dede:sql sql="SELECT typename,typedir,typeimg FROM dede_arctype"}
     <li><a href="[field:typedir/]">[field:typeimg/]</a></li>
  {/dede:sql}

这样就顺利的调出来了,当然如果你要调用子ID的话,只要加上相应的条件ID调用就可以了。

转载于:https://blog.51cto.com/14262733/2370551

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值