http://www.tssn.net

dedecms添加栏目图片并调用

前台调用栏目时需要显示图标,整理一下:
第一步:“系统->SQL命令工具” , 插入sql语句
alter table dede_arctype add typeimg varchar(100)
第二步:进入后台管理文件目录(默认为:dede目录),找到”catelog_add.php“下的 228行,把下面的替换默认的(在SQL语句添加了”typeimg“)
    $in_query = "INSERT INTO `dede_arctype`(reid,topid,sortrank,typename,typedir,isdefault,defaultname,issend,channeltype,
    tempindex,templist,temparticle,modname,namerule,namerule2,
    ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`,`typeimg`)
    VALUES('$reid','$topid','$sortrank','$typename','$typedir','$isdefault','$defaultname','$issend','$channeltype',
    '$tempindex','$templist','$temparticle','default','$namerule','$namerule2',
    '$ispart','$corank','$description','$keywords','$seotitle','$moresite','$siteurl','$sitepath','$ishidden','$cross','$crossid','$content','$smalltypes','$typeimg')";
 
第三步:找到”catelog_edit.php“下的36行把下面的替换默认的(在SQL语句添加了”typeimg“)
复制代码
    $upquery = "UPDATE `dede_arctype` SET
     issend='$issend',
     sortrank='$sortrank',
     typename='$typename',
     typedir='$typedir',
     isdefault='$isdefault',
     defaultname='$defaultname',
     issend='$issend',
     ishidden='$ishidden',
     channeltype='$channeltype',
     tempindex='$tempindex',
     templist='$templist',
     temparticle='$temparticle',
     namerule='$namerule',
     namerule2='$namerule2',
     ispart='$ispart',
     corank='$corank',
     description='$description',
     keywords='$keywords',
     seotitle='$seotitle',
     moresite='$moresite',
     `cross`='$cross',
     `content`='$content',
     `crossid`='$crossid',
     `typeimg`='$typeimg',
     `smalltypes`='$smalltypes'
     $uptopsql
    WHERE id='$id' ";
复制代码
 
第四步:进入后台管理文件目录(默认为:dede目录)/templets/ 下的 “catalog_add.htm 和 catalog_edit.htm" 文件,再加入下面代码:
<script language='javascript' src="js/main.js"></script>
并在想放置的位置加入下面代码:
复制代码
              <tr>
                <td colspan="2">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-bottom:3px;">
                        <tbody>
                            <tr>
                                <td width="90" class="bline" height="24"> imgmm:</td>
                                <td class="bline">
                                    <input type="text" name="typeimg" id="imgmm" style="width:300px" class="text" value="<?php echo $myrow['typeimg']?>" />
                                    <input name="imgmm_bt" type="button" class="inputbut" value="浏览..." onclick="SelectImage('form1.imgmm','big')" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <input type="hidden" name="dede_addonfields" value="imgmm,img" />
                </td>
            </tr>     
复制代码
 
第五步:调用栏目通边 channel 标签调用,所以要更改, 进入/include/taglib/channel.lib.php文件,找到78行,把以下的代码替换默认(添加typeimg字段查询)
复制代码
    if($type=='top')
    {
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typeimg
          From `dede_arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line ";
    }
    else if($type=='son')
    {
        if($typeid==0) return '';
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,content,typeimg
          From `dede_arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit 0, $line ";
    }
    else if($type=='self')
    {
        if($reid==0) return '';
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typeimg
            FROM `dede_arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
    }
复制代码
 
最后一步:就是在前台调用了
        {dede:channel type='self' typeid='15' row='8' currentstyle="<li><a href='~typelink~' class='thisclass'>~typename~</a> </li>"}
        <li><a href='[field:typelink/]'>[field:typename/]</a> <img src='[field:typeimg/]' /></li>
        {/dede:channel}
 

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。