Home  >  Article  >  php教程  >  Add pictures to dedecms backend column

Add pictures to dedecms backend column

WBOY
WBOYOriginal
2016-09-23 11:13:05977browse

The icon needs to be displayed when calling the column at the front desk. Let’s organize it:

Step one: "System->SQL Command Tool", insert sql statement

alter table dede_arctype add imgtype varchar(100)

Step 2: Enter the background management file directory (default: dede directory), find line 228 under "catelog_add.php", and replace the default one with the following (added "typeimg" to the SQL statement)

    $in_query = "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('$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')";

Step 3: Find line 36 under "catelog_edit.php" and replace the default with the following (added "typeimg" to the SQL statement)

    $upquery = "UPDATE `#@__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' ";

Step 4: Enter the "catalog_add.htm and catalog_edit.htm" files under the background management file directory (default: dede directory)/templets/, and then add the following code:

<script language='javascript' src="js/main.js">script>

And add the following code where you want to place it:

            <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" /> 
                                    <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>

Step 5: Call the column channel tag call, so you need to change it. Enter the /include/taglib/channel.lib.php file, find line 78, and replace the following code with the default (add typeimg field query)

    if($type=='top')
    {
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typeimg
          From `#@__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 `#@__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 `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
    }

The last step: call it at the front desk

        {dede:channel type='self' typeid='15' row='8' currentstyle="
  • ~typename~
  • "}
  • [field:typename/]
  • {/dede:channel}

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn