Home > Backend Development > PHP Tutorial > Detailed introduction to 4 commonly used functions of DedeCMS

Detailed introduction to 4 commonly used functions of DedeCMS

黄舟
Release: 2023-03-07 08:46:02
Original
1363 people have browsed it

This article mainly introduces the four commonly used functions of DedeCMS. This article introduces GetCurUrl(), GetAlabNum(), Text2Html(), and ClearHtml() respectively. For the functions and usage of three commonly used functions, friends in need can refer to them

As we all know, dedecms supports [field:senddate function=”strftime('%y-%m-%d %H:%M',@me)"/] Some usages like this are to use function within the tag and call the relevant function to reprocess the content returned by the current tag before displaying it. come out.

Take the above mark as an example. Originally, the program displayed the senddate field of a certain table in the database, but by looking at the database, it was found that senddate was just a large series of numbers, not the time format we wanted. The PHP language itself has There are some built-in functions for time processing. strftime is a function that comes with PHP itself. Of course, you can also extend it and write your own functions. We don’t need to display these numbers on the template. We need to convert them into our time according to a certain format. , then you can use this function for processing.

dedecms template download address: www.php.cn/xiazai/code/dedecms

Let’s analyze how to use some common functions that dedecms comes with:

GetCurUrl()

This is probably not used too much. This function obtains the address of the currently running script. You can use it in the following ways:

The code is as follows:

{dede:CurUrl runphp='yes'}
@me = GetCurUrl();
{/dede:CurUrl}
Copy after login

GetAlabNum()

Returns a half-width number. If you do not want full-width numbers to appear in a certain field information, you can use this function, for example:
[field: listnum/] returns 12234. I hope it is a half-width number 12234. You can use the function like this:

The code is as follows:

[field:listnum function=”GetAlabNum(@me)”/]
Copy after login

Text2Html( )

Text to HTML, the function converts spaces, <, >... and other characters in the text content into HTML tags. It can be used like this:

The code is as follows :

[field:textcontent function=”Text2Html(@me)”/]
Copy after login

There is also a reverse function here, which converts html to Text, Html2Text(). Its usage is similar to

ClearHtml()

Clear html tags, the function clears the html tags contained in the content. Usage:

The code is as follows:

[field:content function=”ClearHtml(@me)”/]
Copy after login


The above is the detailed content of Detailed introduction to 4 commonly used functions of DedeCMS. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template