How to add column pictures in Dreamweaver CMS
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.
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:
<script language='javascript' src="js/main.js"></script>
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('form1.imgmm','big')" /> </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['typeimg']?>" /> <input name="imgmm_bt" type="button" class="inputbut" value="浏览..." onclick="SelectImage('form1.imgmm','big')" /> </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=='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,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 "; }
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="<li><a href='~typelink~' class='thisclass'>~typename~</a> </li>"}<li><a href='[field:typelink/]'>[field:typename/]</a> <img src='[field:typeimg/]' /></li>{/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['typeimg']; if($action="images") return $toptypeimg;
The front-end calling method:
<img src="{dede:field.typeid function=gettoptype(@me,images)/}">
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['topid'] == '0') { return $row['typeimg']; } else { $row1 = $dsql->GetOne("SELECT typeimg FROM dede_arctype WHERE id= $row[topid]"); return $row1['typeimg']; } }
The front-end calling method is:
<img src="{dede:field name='typeid' function="GetTopTypeimg(@me)" /}">
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Dream Weaver CMS Station Group Practice Sharing In recent years, with the rapid development of the Internet, website construction has become more and more important. When building multiple websites, site group technology has become a very effective method. Among the many website construction tools, Dreamweaver CMS has become the first choice of many website enthusiasts due to its flexibility and ease of use. This article will share some practical experience about Dreamweaver CMS station group, as well as some specific code examples, hoping to provide some help to readers who are exploring station group technology. 1. What is Dreamweaver CMS station group? Dream Weaver CMS

The security of DreamWeaver cms is relatively good for the following reasons: 1. Fast vulnerability repair; 2. CSRF (cross-site request forgery) protection; 3. XSS (cross-site scripting attack) protection; 4. SQL injection protection; 5. Code audit.

There is no charge for the Dreamweaver CMS system. Dreamweaver CMS is an open source content management system. Its core code is provided for free. Users can download the latest version of Dreamweaver CMS for free and obtain relevant technical support and documentation. However, during use, users may need to purchase additional functional modules or theme templates, which are chargeable. The price for purchasing these paid modules and templates depends on the specific functions and design complexity.

Title: Analysis of the reasons and solutions for why the secondary directory of DreamWeaver CMS cannot be opened. Dreamweaver CMS (DedeCMS) is a powerful open source content management system that is widely used in the construction of various websites. However, sometimes during the process of building a website, you may encounter a situation where the secondary directory cannot be opened, which brings trouble to the normal operation of the website. In this article, we will analyze the possible reasons why the secondary directory cannot be opened and provide specific code examples to solve this problem. 1. Possible cause analysis: Pseudo-static rule configuration problem: during use

Solution to the failure of Dreamweaver CMS to connect to the database: 1. Check the database configuration and ensure that the relevant information of the database is correctly set in the /data/config.php file in the root directory of Dreamweaver CMS; 2. Test the database connection by creating a A simple PHP script to test whether the database connection is successful; 3. Check the database server status and change the database server address in the /data/config.php file in the root directory of DreamWeaver CMS; 4. Check the network connection.

Dreamweaver CMS is a very popular website construction system with powerful functions, friendly interface and easy to use. But sometimes, we will find that to achieve some special needs, the functions it originally provided may not be enough. In response to this situation, we can carry out secondary development and realize personalized website needs through customized code. This article will share some secrets about the secondary development of DreamWeaver CMS to help you unlock the skills of personalized website customization. 1. Description of customization requirements for homepage carousel: original DreamWeaver CMS homepage

Sorry, I can't provide information on cracking or bypassing the captcha. If you have any further questions or need help, please feel free to let me know.

Title: Things to note when deleting database files of Dreamweaver CMS. As a popular website construction tool, the deletion of database files of Dreamweaver CMS is one of the problems often encountered in website maintenance. Incorrect database file deletion operations may result in website data loss or website failure to function properly. Therefore, we must be extremely cautious when performing database file deletion operations. The following will introduce the precautions for deleting Dreamweaver CMS database files, and provide some specific code examples to help you correctly delete database files. Note: prepare
