Home > Article > Backend Development > Detailed introduction to 4 commonly used functions of DedeCMS
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: m.sbmmt.com/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}
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)”/]
Text2Html( )
Text to HTML, the function converts spaces, 95ec6993dc754240360e28e0de8de30a... 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)”/]
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)”/]
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!