Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does the dream weaving CMS judge the output

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how the dream weaving CMS judges the output. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

Dream weaving CMS how to achieve judgment output?

Detailed explanation of several Field judgment output examples commonly used in Dream Weaving CMS

When we use Weaving Dream CMS to make a website, we occasionally use some judgment statements to achieve our requirements for a certain field, whether it is a default field or a custom field. Several common requirements are listed below. And an example of the judgment output of the field.

The first kind: weaving dream custom field, if there is no value, the specified default content will be displayed.

{dede:field name='ziduan' runphp='yes'} if (@ me=='') {@ me='';} else {@ me= "here is custom content";} {/ dede:field}

Second: DedeCMS judges that if the abbreviated title is empty, the full title will be displayed.

Method 1, suitable for content pages

{dede:field name='array' runphp='yes'} if (@ me ['shorttitle'] = ='') @ me=@me ['title']; else @ me=@me [' shorttitle']; {/ dede:field}

Method 2, which applies to the list page

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

The third kind: 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]

This 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 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. The HR.png here is just a string that represents the location of the image file. You can set any image path. The above code is a branch conditional output statement. @ me represents the output variable. When you enter the tag field:array, @ me represents a record in the database, and its data type is an array. We judge according to the value of risklevle in it, thus setting @ me to a different value. When you exit the tag field:array, the value of @ me will be displayed in the original location.

Fourth: other fields need to be called in the process of judgment.

You need to make a small judgment in the template. If the download address of the article is directly output when the price of the article is 0, otherwise the purchase link will be output directly, then you will definitely need to run the runphp='yes' function at this time. Let's take a look at the code:

After searching, it is found that the two methods can basically be implemented.

1. First, put the values of other fields that need to be called in the public variable, and then directly call the value of the common 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= "download address:. $GLOBALS ['baidupan']; else@me =" goods (". $GLOBALS [' title'].") purchase link is: 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=' download:'. @ me ['baidupwd'].'; else@me ='

'; {/ dede:field}

Above many points need to pay attention to symbols, single quotation marks, double quotation marks.

Thank you for reading! About weaving dream CMS is how to judge the output is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report