首页 > php教程 > php手册 > dedecms 后台栏目添加图片

dedecms 后台栏目添加图片

WBOY
发布: 2016-09-23 11:13:05
原创
1105 人浏览过

前台调用栏目时需要显示图标,整理一下:

第一步:“系统->SQL命令工具” , 插入sql语句

alter table dede_arctype add imgtype varchar(<span style="color: #800080;">100</span>)
登录后复制

第二步:进入后台管理文件目录(默认为:dede目录),找到”catelog_add.php“下的 228行,把下面的替换默认的(在SQL语句添加了”typeimg“)

    <span style="color: #800080;">$in_query</span> = "<span style="color: #000000;">INSERT INTO `#@__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('</span><span style="color: #800080;">$reid</span>','<span style="color: #800080;">$topid</span>','<span style="color: #800080;">$sortrank</span>','<span style="color: #800080;">$typename</span>','<span style="color: #800080;">$typedir</span>','<span style="color: #800080;">$isdefault</span>','<span style="color: #800080;">$defaultname</span>','<span style="color: #800080;">$issend</span>','<span style="color: #800080;">$channeltype</span><span style="color: #000000;">',
    '</span><span style="color: #800080;">$tempindex</span>','<span style="color: #800080;">$templist</span>','<span style="color: #800080;">$temparticle</span>','default','<span style="color: #800080;">$namerule</span>','<span style="color: #800080;">$namerule2</span><span style="color: #000000;">',
    '</span><span style="color: #800080;">$ispart</span>','<span style="color: #800080;">$corank</span>','<span style="color: #800080;">$description</span>','<span style="color: #800080;">$keywords</span>','<span style="color: #800080;">$seotitle</span>','<span style="color: #800080;">$moresite</span>','<span style="color: #800080;">$siteurl</span>','<span style="color: #800080;">$sitepath</span>','<span style="color: #800080;">$ishidden</span>','<span style="color: #800080;">$cross</span>','<span style="color: #800080;">$crossid</span>','<span style="color: #800080;">$content</span>','<span style="color: #800080;">$smalltypes</span>','<span style="color: #800080;">$typeimg</span>')";
登录后复制

 

第三步:找到”catelog_edit.php“下的36行把下面的替换默认的(在SQL语句添加了”typeimg“)

    <span style="color: #800080;">$upquery</span> = "<span style="color: #000000;">UPDATE `#@__arctype` SET
     issend='</span><span style="color: #800080;">$issend</span><span style="color: #000000;">',
     sortrank='</span><span style="color: #800080;">$sortrank</span><span style="color: #000000;">',
     typename='</span><span style="color: #800080;">$typename</span><span style="color: #000000;">',
     typedir='</span><span style="color: #800080;">$typedir</span><span style="color: #000000;">',
     isdefault='</span><span style="color: #800080;">$isdefault</span><span style="color: #000000;">',
     defaultname='</span><span style="color: #800080;">$defaultname</span><span style="color: #000000;">',
     issend='</span><span style="color: #800080;">$issend</span><span style="color: #000000;">',
     ishidden='</span><span style="color: #800080;">$ishidden</span><span style="color: #000000;">',
     channeltype='</span><span style="color: #800080;">$channeltype</span><span style="color: #000000;">',
     tempindex='</span><span style="color: #800080;">$tempindex</span><span style="color: #000000;">',
     templist='</span><span style="color: #800080;">$templist</span><span style="color: #000000;">',
     temparticle='</span><span style="color: #800080;">$temparticle</span><span style="color: #000000;">',
     namerule='</span><span style="color: #800080;">$namerule</span><span style="color: #000000;">',
     namerule2='</span><span style="color: #800080;">$namerule2</span><span style="color: #000000;">',
     ispart='</span><span style="color: #800080;">$ispart</span><span style="color: #000000;">',
     corank='</span><span style="color: #800080;">$corank</span><span style="color: #000000;">',
     description='</span><span style="color: #800080;">$description</span><span style="color: #000000;">',
     keywords='</span><span style="color: #800080;">$keywords</span><span style="color: #000000;">',
     seotitle='</span><span style="color: #800080;">$seotitle</span><span style="color: #000000;">',
     moresite='</span><span style="color: #800080;">$moresite</span><span style="color: #000000;">',
     `cross`='</span><span style="color: #800080;">$cross</span><span style="color: #000000;">',
     `content`='</span><span style="color: #800080;">$content</span><span style="color: #000000;">',
     `crossid`='</span><span style="color: #800080;">$crossid</span><span style="color: #000000;">',
     `typeimg`='</span><span style="color: #800080;">$typeimg</span><span style="color: #000000;">',
     `smalltypes`='</span><span style="color: #800080;">$smalltypes</span><span style="color: #000000;">'
     </span><span style="color: #800080;">$uptopsql</span><span style="color: #000000;">
    WHERE id='</span><span style="color: #800080;">$id</span>' ";
登录后复制

 

第四步:进入后台管理文件目录(默认为:dede目录)/templets/ 下的 “catalog_add.htm 和 catalog_edit.htm" 文件,再加入下面代码:

<span style="color: #0000ff;"><span style="color: #800000;">script </span><span style="color: #ff0000;">language</span><span style="color: #0000ff;">='javascript' </span><span style="color: #ff0000;">src</span><span style="color: #0000ff;">="js/main.js"</span><span style="color: #0000ff;">></span><span style="color: #800000;">script</span><span style="color: #0000ff;">></span></span>
登录后复制

并在想放置的位置加入下面代码:

            <span style="color: #0000ff;"><span style="color: #800000;">tr</span><span style="color: #0000ff;">></span>
                <span style="color: #0000ff;"><span style="color: #800000;">td </span><span style="color: #ff0000;">colspan</span><span style="color: #0000ff;">="2"</span><span style="color: #0000ff;">></span>
                    <span style="color: #0000ff;"><span style="color: #800000;">table </span><span style="color: #ff0000;">width</span><span style="color: #0000ff;">="100%"</span><span style="color: #ff0000;"> border</span><span style="color: #0000ff;">="0"</span><span style="color: #ff0000;"> cellspacing</span><span style="color: #0000ff;">="0"</span><span style="color: #ff0000;"> cellpadding</span><span style="color: #0000ff;">="0"</span><span style="color: #ff0000;"> style</span><span style="color: #0000ff;">="margin-bottom:3px;"</span><span style="color: #0000ff;">></span>
                        <span style="color: #0000ff;"><span style="color: #800000;">tbody</span><span style="color: #0000ff;">></span>
                            <span style="color: #0000ff;"><span style="color: #800000;">tr</span><span style="color: #0000ff;">></span> 
                                <span style="color: #0000ff;"><span style="color: #800000;">td </span><span style="color: #ff0000;">width</span><span style="color: #0000ff;">="90"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="bline"</span><span style="color: #ff0000;"> height</span><span style="color: #0000ff;">="24"</span><span style="color: #0000ff;">></span><span style="color: #ff0000;"> </span>imgmm:<span style="color: #0000ff;"></span><span style="color: #800000;">td</span><span style="color: #0000ff;">></span>
                                <span style="color: #0000ff;"><span style="color: #800000;">td </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="bline"</span><span style="color: #0000ff;">></span>
                                    <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="text"</span><span style="color: #ff0000;"> name</span><span style="color: #0000ff;">="typeimg"</span><span style="color: #ff0000;"> id</span><span style="color: #0000ff;">="imgmm"</span><span style="color: #ff0000;"> style</span><span style="color: #0000ff;">="width:300px"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="text"</span> <span style="color: #0000ff;">/></span> 
                                    <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="imgmm_bt"</span><span style="color: #ff0000;"> type</span><span style="color: #0000ff;">="button"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="inputbut"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="浏览..."</span><span style="color: #ff0000;"> onclick</span><span style="color: #0000ff;">="SelectImage('form1.imgmm','big')"</span> <span style="color: #0000ff;">/></span>
                                <span style="color: #0000ff;"></span><span style="color: #800000;">td</span><span style="color: #0000ff;">></span>
                            <span style="color: #0000ff;"></span><span style="color: #800000;">tr</span><span style="color: #0000ff;">></span>
                        <span style="color: #0000ff;"></span><span style="color: #800000;">tbody</span><span style="color: #0000ff;">></span>
                    <span style="color: #0000ff;"></span><span style="color: #800000;">table</span><span style="color: #0000ff;">></span>
                    <span style="color: #0000ff;"><span style="color: #800000;">input </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="hidden"</span><span style="color: #ff0000;"> name</span><span style="color: #0000ff;">="dede_addonfields"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="imgmm,img"</span> <span style="color: #0000ff;">/></span>
                <span style="color: #0000ff;"></span><span style="color: #800000;">td</span><span style="color: #0000ff;">></span>
            <span style="color: #0000ff;"></span><span style="color: #800000;">tr</span><span style="color: #0000ff;">></span></span></span></span></span></span></span></span></span></span></span>
登录后复制

 

第五步:调用栏目通边 channel 标签调用,所以要更改, 进入/include/taglib/channel.lib.php文件,找到78行,把以下的代码替换默认(添加typeimg字段查询)

    <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$type</span>=='top'<span style="color: #000000;">)
    {
        </span><span style="color: #800080;">$sql</span> = "<span style="color: #000000;">SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typeimg
          From `#@__arctype` WHERE reid=0 And ishidden1 order by sortrank asc limit 0, </span><span style="color: #800080;">$line</span> "<span style="color: #000000;">;
    }
    </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$type</span>=='son'<span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">if</span>(<span style="color: #800080;">$typeid</span>==0) <span style="color: #0000ff;">return</span> ''<span style="color: #000000;">;
        </span><span style="color: #800080;">$sql</span> = "<span style="color: #000000;">SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,content,typeimg
          From `#@__arctype` WHERE reid='</span><span style="color: #800080;">$typeid</span>' And ishidden1 order by sortrank asc limit 0, <span style="color: #800080;">$line</span> "<span style="color: #000000;">;
    }
    </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$type</span>=='self'<span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">if</span>(<span style="color: #800080;">$reid</span>==0) <span style="color: #0000ff;">return</span> ''<span style="color: #000000;">;
        </span><span style="color: #800080;">$sql</span> = "<span style="color: #000000;">SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typeimg
            FROM `#@__arctype` WHERE reid='</span><span style="color: #800080;">$reid</span>' And ishidden1 order by sortrank asc limit 0, <span style="color: #800080;">$line</span> "<span style="color: #000000;">;
    }</span>
登录后复制

 

最后一步:就是在前台调用了

        {dede:channel type='self' typeid='15' row='8' currentstyle="
登录后复制
  • ~typename~
  • "}
  • [field:typename/] dedecms 后台栏目添加图片
  • {/dede:channel}

     

    来源:php.cn
    本站声明
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
    热门推荐
    热门教程
    更多>
    最新下载
    更多>
    网站特效
    网站源码
    网站素材
    前端模板