Home >CMS Tutorial >DEDECMS >How to add column pictures in Dreamweaver CMS

How to add column pictures in Dreamweaver CMS

藏色散人
藏色散人Original
2023-03-14 10:42:301854browse

How to add column pictures in Dream Weaver CMS: 1. Name the column picture field to be added "typeimg", and the execution code is "alter table dede_arctype add typeimg varchar(100)"; 2. Modify "catelog_add" .php" and "catelog_edit.php" file contents; 3. Use the channel tag to call the column, and then get the top column image of the current column.

How to add column pictures in Dreamweaver CMS

The operating environment of this tutorial: Windows 10 system, DedeCMS version 5.7, Dell G3 computer.

How to add column pictures in DreamWeaver cms?

dedecms (Dreamweaver CMS) code method for adding column images in the background

Although the methods on the Internet are correct, some details are not handled well, and many novices will encounter problems. Let me summarize it next.

The first step is to add the column image field. I will name the field typeimg here. You can add code in the background and execute the code. The operation is as follows:
"System-> SQL command tool", insert sql statement
alter table dede_arctype add typeimg varchar(100)
Step 2: Enter the background management file directory (default: dede directory), find several places under "catelog_add.php" To be modified.
1. Find $queryTemplate (about 65 lines)
The code I changed is as follows:

$queryTemplate = "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~','~rank~','~typename~','~typedir~','$isdefault','$defaultname','$issend','$channeltype',
    '$tempindex','$templist','$temparticle','default','$namerule','$namerule2','0','0','','','~typename~','0','','','0','0','0','','','~typeimg~')";

2. Find $in_query (about 227 lines)

Modify the entire $in_query

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

In fact, it’s not difficult. Newbies can copy and paste, and veterans can modify it by themselves, just add a typeimg field to the statement.
Step 3: In the same way, find $upquery under "catelog_edit.php" (about line 38)
Modify the code as follows

$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 background management file directory (default is : dede directory)/templets/ under the "catalog_add.htm and catalog_edit.htm" files, add the following code between:

4df64949a418eaaac6f0491cdce4fee62cacc6d41bbb37262a98f745aa00fbf0

catalog_add.htm Add the following code

<!--加入栏目-->
<tr>
<td class="bline" height="26" style="padding-left:10px;">栏目图片:</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(&#39;form1.imgmm&#39;,&#39;big&#39;)" />
</td>
<input type="hidden" name="dede_addonfields" value="imgmm,img" />
</tr>

catalog_edit.htm Add the following code

<!--加入栏目-->
<tr>
<td class="bline" height="26" style="padding-left:10px;">栏目图片:</td>
<td class="bline">
<input type="text" name="typeimg" id="imgmm" style="width:300px" class="text" value="<?php echo $myrow[&#39;typeimg&#39;]?>" />
<input name="imgmm_bt" type="button" class="inputbut" value="浏览..." onclick="SelectImage(&#39;form1.imgmm&#39;,&#39;big&#39;)" />
</td>
<input type="hidden" name="dede_addonfields" value="imgmm,img" />
</tr>

Note: The codes of these two files are different and must be added separately.

Step 5: If you use the channel tag to call the column, you need to change the /include/taglib/channel.lib.php file and find the following code to replace it

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

In fact, it is The typeimg field is added to the sql statement.
The sixth step is to call

{dede:channel type='self' typeid='15' row='8' currentstyle="25edfb22a4f469ecb59f1190150159c68d60d59de777e50e50090b37959b0985~typename~5db79b134e9f6b82c0b36e0489ee08ed bed06894275b65c1ab86501b08a632eb"}25edfb22a4f469ecb59f1190150159c65ab648ad8fc41adf601551917280b087[field:typename/]5db79b134e9f6b82c0b36e0489ee08ed eb1070f765392fe362bd87515babcaeebed06894275b65c1ab86501b08a632eb{/dede:channel}

The above code is online. What I want is not this effect. If I get the top column picture of the current column

I use two methods to solve this problem:
I tested it and it works
The first method:
Modify the file include/helpers/extend.helper.php
Find the gettoptype function and add the following to it Code, the purpose is to get the column picture

//增加栏目图片
$toptypeimg=$row[&#39;typeimg&#39;];
if($action="images") return $toptypeimg;

The front-end calling method:

58a4381fe43a7333eff0607c269bbf9e

This way you can call it. Perfect! !

Second method:
Modify the file include/common.func.php
Just add a function at the end, as follows:

//获取顶级栏目的栏目图片 李国平更新于2021.3.11
function GetTopTypeimg($id)
{
global $dsql;  
$row = $dsql->GetOne("SELECT typeimg,topid FROM dede_arctype WHERE id= $id");
if ($row[&#39;topid&#39;] == &#39;0&#39;) 
{ 
return $row[&#39;typeimg&#39;];  
} 
else 
{ 
$row1 = $dsql->GetOne("SELECT typeimg FROM dede_arctype WHERE id= $row[topid]"); 
return $row1[&#39;typeimg&#39;]; 
} 
}

The front-end calling method is:

349f82663f400e28b106a4f93a2eb326

This can also be called. Perfect! !

Recommended learning: dedecms tutorial

The above is the detailed content of How to add column pictures in Dreamweaver CMS. For more information, please follow other related articles on the PHP Chinese website!

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