search
HomeCMS TutorialDEDECMSHow does DreamWeaver CMS realize judgment output?

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=&#39;red&#39;><a href=&#39;/.@me&#39;>此处是自定义的内容</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=&#39;array&#39; runphp=&#39;yes&#39;}
 if (@me[&#39;shorttitle&#39;]==&#39;&#39;) 
@me=@me[&#39;title&#39;]; 
  
else
 @me=@me[&#39;shorttitle&#39;];
 {/dede:field}

Method 2, applicable to list pages

[field:array runphp=&#39;yes&#39;]
 if (@me[&#39;shorttitle&#39;]==&#39;&#39;) @me=@me[&#39;title&#39;]; 
else @me=@me[&#39;shorttitle&#39;]; 
[/field:array]

The third type: multiple judgments on a certain field

[field:array runphp=&#39;yes&#39;]
 if(@me[&#39;risklevel&#39;]=="HR")@me="HR.png"; 
else if(@me[&#39;risklevel&#39;]=="D")@me="D.png"; 
else if(@me[&#39;risklevel&#39;]=="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[&#39;title&#39;]=$arc->Fields[&#39;title&#39;]{/dede:php} 
{dede:php}$GLOBALS[&#39;baidupan&#39;]=$arc->Fields[&#39;baidupan&#39;]{/dede:php} 
{dede:field.price runphp="yes"}
if(@me="0")
@me = "下载地址:".$GLOBALS[&#39;baidupan&#39;];
else
@me = "商品(".$GLOBALS[&#39;title&#39;].")购买链接为: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=&#39;array&#39; runphp=&#39;yes&#39;}
if(@me[&#39;price&#39;]==&#39;0&#39; )
@me = &#39;
<li><a class="demo" href="&#39;.@me[&#39;baidupan&#39;].&#39;" target="_blank">下载:&#39;.@me[&#39;baidupwd&#39;].&#39;</a></li>
&#39;;
else
@me = &#39;
<div id="pdBuy" class="PDB2C_moban_warp" dataP="&#39;.@me[&#39;title&#39;].&#39;" dataR="&#39;.@me[&#39;price&#39;].&#39;"><img  src="/static/imghwm/default1.png"  data-src="/uploads/allimg/170702/155R26021-0.gif"  class="lazy"   alt="How does DreamWeaver CMS realize judgment output?" ></div>
&#39;;
{/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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software