How does DreamWeaver CMS realize judgment output?
How does DreamWeaver CMS achieve judgment output?
Detailed explanation of several commonly used field judgment output examples of Dreamweaver CMS
When we use Dreamweaver CMS to create a website, for a certain field, whether it is a default field or a custom field , and occasionally use some judgment statements to achieve our needs. Several common requirements are listed below. And the judgment output example of the field.
Recommended learning: DreamWeaver cms
The first type: DreamWeaver custom field, if there is no value, the specified default content should be displayed,
{dede:field name='ziduan' runphp='yes'} if(@me=='') { @me = '' ;} else { @me = "<div class='red'><a href='/.@me'>此处是自定义的内容</a></div>"; } {/dede:field}
Second type: DedeCMS will display the complete title when it determines that the abbreviated title is empty
Method 1, applicable to content pages
{dede:field name='array' runphp='yes'} if (@me['shorttitle']=='') @me=@me['title']; else @me=@me['shorttitle']; {/dede:field}
Method 2, applicable to list pages
[field:array runphp='yes'] if (@me['shorttitle']=='') @me=@me['title']; else @me=@me['shorttitle']; [/field:array]
The third type: multiple judgments on a certain field
[field:array runphp='yes'] if(@me['risklevel']=="HR")@me="HR.png"; else if(@me['risklevel']=="D")@me="D.png"; else if(@me['risklevel']=="AA")@me="AA.png"; [/field:array]
The above means that if the value of the risk level field obtained by the query is HR, then HR.png will be output. If the value of the risk level field obtained by the query is The value of is D, then D.png will be output. If the value of the risk level field obtained by the query is AA, then AA.png will be output. HR.png here is just a string, representing the location of the image file. , you can set it to any image path. The above code is a branch conditional output statement. @me represents the output variable. When you first enter the label field:array, @me represents a record in the database, and its data type is an array. , we judge based on the value of risklevle, thereby setting @me to different values. When exiting the label field:array, the value of @me will be displayed in the original position.
The fourth type: other fields need to be called during the judgment process.
You need to make a small judgment in the template. If the price of the article is 0, the download address will be directly output. Otherwise, the purchase link will be output directly. Then you must run the runphp='yes' function at this time. Let's take a look at the code:
After searching, we found that two methods can basically be implemented
1. First, put the values that need to call other fields in public variables, and then directly call the public For the value of the variable, see the code
{dede:php}$GLOBALS['title']=$arc->Fields['title']{/dede:php} {dede:php}$GLOBALS['baidupan']=$arc->Fields['baidupan']{/dede:php} {dede:field.price runphp="yes"} if(@me="0") @me = "下载地址:".$GLOBALS['baidupan']; else @me = "商品(".$GLOBALS['title'].")购买链接为:XXX"; {/dede:field.xxxx}
2. Directly use name='array' to assign the values of other fields to the array, and then use it. See the code
{dede:field name='array' runphp='yes'} if(@me['price']=='0' ) @me = ' <li><a class="demo" href="'.@me['baidupan'].'" target="_blank">下载:'.@me['baidupwd'].'</a></li> '; else @me = ' <div id="pdBuy" class="PDB2C_moban_warp" dataP="'.@me['title'].'" dataR="'.@me['price'].'"><img src="/uploads/allimg/170702/155R26021-0.gif"></div> '; {/dede:field}
. Many of the above points require attention to symbols. , single quotes, double quotes.
The above is the detailed content of How does DreamWeaver CMS realize judgment output?. 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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

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

DedeCMS is a content management system widely used in website construction, providing rich functions and flexible customization. However, sometimes we need to delete some files in the database to clean up space or solve some problems. This article will introduce how to delete database files in Dreamweaver CMS and provide specific code examples. Step 1: Back up the database Before performing any database operations, be sure to back up the database to prevent accidents. You can use phpMyAdmin or other numbers
