第一步:
新加字段 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>
我试了一下在模版里用:{dede:field.typeimg /} 是调不出数据的,所以我改成了SQL调用。 原来是这样的:
{dede:channel type='top' row='13'}
<li><a rel="nofollow" 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 rel="nofollow" href="[field:typedir/]">[field:typeimg/]</a></li>
{/dede:sql}
这样就顺利的调出来了,当然如果你要调用子ID的话,只要加上相应的条件ID调用就可以了。