This article mainly introduces the 4 common functions of weaving dream dedecms, this paper introduces the function and use method of 3 common functions such as Getcururl (), Getalabnum (), text2html (), clearhtml (), and so on, the need of friends can refer to
As you all know, Dedecms supports some usages of [Field:senddate function= "strftime ('%y-%m-%d%h:%m ', @me)"/], that is, the use of function within the tag, Call the relevant function to re-process the contents returned by the current label and display it again.
Take the above mark as an example, the program shows the database of a table field senddate, but by looking at the database discovery, Senddate is just a bunch of numbers, not the time format we want, the PHP language itself for time processing is some of its own functions, Strftime is the function of PHP itself, of course, you can also expand, write their own functions, the template we do not need to display these numbers, we need to follow a certain format conversion to our time, then we can use this function for processing.
Dedecms template Download Address: www.php.cn/xiazai/code/dedecms
Let's analyze the use of some common functions of dedecms:
Getcururl ()
This estimate does not use too much, this function obtains the currently running script address, can use in the following way:
The code is as follows:
{dede:cururl runphp= ' yes '} @me = Getcururl (); {/dede:cururl}
Getalabnum ()
To return half-width numbers, you can use this function if you do not want the full-width number of a field information, for example:
[field:listnum/] returned is 12234, I would like to be the half-width of the number 12234, you can use the function:
The code is as follows:
[Field:listnum function= "Getalabnum (@me)"/]
Text2html ()
Text to HTML, function will be the text content of space, <, ... and other characters into HTML tags, you can use this:
The code is as follows:
[Field:textcontent function= "text2html (@me)"/]
Also here is an inverse function, which converts HTML to text, Html2text (), which uses a similar
Clearhtml ()
Clears the HTML tag, and the function clears the HTML markup contained in the content. Usage:
The code is as follows:
[Field:content function= "clearhtml (@me)"/]