Dedecms common function parser _ PHP Tutorial

Source: Internet
Author: User
Dedecms common function parsing. As we all know, dedecms supports some usage such as [field: senddatefunction "strftime (% y-% m-% d % H: % M, @ me, that is, the function is used in the tag. it is known that dedecms supports [field: senddate function = "strftime ('% y-% m-% d % H: % M', @ me) "/] is used to call related functions to re-process the content returned by the current tag and display it.

Take the above mark as an example. The program originally showed the field senddate of a table in the database. However, by viewing the database, we found that senddate is only a large string of numbers, not the desired time format, the PHP language itself has some built-in functions for time processing. strftime is the built-in function of php itself. of course, you can also extend it and write your own functions, we do not need to display these numbers in the template. we need to convert them to our time in a certain format. in this case, we can use this function for processing.


Next we will analyze how dedecms comes with some common functions:

■ GetCurUrl ()

This estimate is not used too much. this function obtains the currently running script address, which can be used in the following ways:
{Dede: CurUrl runphp = 'yes '}
@ Me = GetCurUrl ();
{/Dede: CurUrl}

■ GetAlabNum ()

Returns a half-width number. if you do not want a full-width number in a field, you can use this function. for example:
[Field: listnum/] the returned value is 12234. I want to use the half-width number 12234. you can use the function as follows:
[Field: listnum function = "GetAlabNum (@ me)"/]

■ Text2Html ()

Convert text to HTML. the Function converts spaces, <,>... Can be used as follows:
[Field: textcontent function = "Text2Html (@ me)"/]
There is also an opposite function here, which converts html to Text, Html2Text (), and its usage is similar

■ ClearHtml ()

Clear the html tag. the Function clears the html tag contained in the content. Usage:
[Field: content function = "ClearHtml (@ me)"/]

Usage ('% y-% m-% d % H: % M', @ me) "/], that is, using function in tag, call the relevant function to return the current tag...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.