Introduction to the use of CMS to call PHP Functions

Source: Internet
Author: User

=================== Introduction to calling PHP functions by the Emperor CMS ====================

1. esub () truncation field function
Syntax:
Esub (string, truncated word count, suffix)
Note:This parameter can be omitted if it is suffixed with a truncated character and is included with the content.
Example:
<? = Esub ('000000', 6)?>, The returned result is 123456.
<? = Esub ('000000', 6, '...')?>, The returned result is: 123456...

Ii. Date () conversion time format Function
Syntax:Date (time format, timestamp)
Note:PHP functions. For instructions, refer:Http://cn2.php.net/manual/en/function.date.php
Example:
<? = Date ('Y-m-d h: I: s', 1277865010)?>, Returned result: 10:30:10

Iii. format_datetime () conversion time format function 2
Syntax:Format_datetime (normal time, time format)
Note:The difference between format_datetime and date () Is that format_datetime is the normal conversion time, while date is the Unix timestamp.
Example:
<? = Format_datetime ('2017-06-30 10:30:10 ','m/D')?>, The returned result is 06/30.

4. Obtain the topic address function by ID
Syntax:Sys_returnbqclassname ($ R, 9)
Note:$ R is an array containing column IDs. Variable names can be named at will.
Example:Obtain the topic address with topic id = 2.
<? PHP
$ Cr ['classid '] = 2;
$ Classurl = sys_returnbqclassname ($ Cr, 9 );
Echo $ classurl;
?>

Other methods to obtain the topic address by ID:
(1),/e/public/classurl /? Topic ID
(2),/<? = $ Class_r [Topic id] ['classpath']?>

 

=================== Introduction to calling PHP functions by the Emperor CMS ====================

V. Page address function for retrieving information content
Syntax:Sys_returnbqtitlelink ($ R)
Note:$ R is an array containing the content of the "ID, classid, newspath, filename, groupid, titleurl" field. The variable name can be any name.
Example:Obtain the news page address with information Id = 8
<? PHP
$ Nr = $ empire-> fettings ("select ID, classid, newspath, filename, groupid, titleurl from {$ dbtbpre} ecms_news where id = '8' limit 1 ");
$ Titleurl = sys_returnbqtitlelink ($ nr );
Echo $ titleurl;
?>

Other methods to obtain the page address of information by ID:
/E/public/infourl /? Classid = topic ID & id = Information ID

6. Information function 1
Syntax: printerror ($ error, $ gotourl, $ ecms, $ noautourl, $ novar)
Note:
$ error: Message content, which can be a Language Pack variable, you can also directly prompt the content.
$ gotourl: indicates the Redirection URL.
$ ecms: 0 indicates the background prompt, 1 indicates the foreground prompt, and 8 indicates the background prompt (alert mode), 9 indicates the front-end prompt information (alert mode)
$ noautourl: 0 indicates the automatic redirect page, and 1 indicates the automatic redirect page. This parameter can be omitted. The default value is 0.
$ novar: 0 indicates that the prompt information content adopts the Language Pack variable, and 1 indicates that the prompt information content is the direct prompt content. This parameter can be omitted. The default value is 0.
example:
printerror ('dberror ', 'HTTP: // www.phome.net ', 1) the front-end prompts that the message content is the dberror variable content of the Language Pack and is directed to the Empire website
printerror ('database error', 'HTTP: // www.phome.net, 1) the front-end prompts that the message content is "database error" and you are redirected to the Empire website
additional instructions:
This function uses the $ editor variable to determine the directory level. The default $ editor variable is 0.
when the Program file is in the/e/path/directory, $ editor does not need to be set, that is, the default value 0 is used.
when the program file is in the/e/path/path2/directory, $ editor = 1.
when the program file is in the/e/path/path2/path3/directory, $ editor = 2.
when the program file is in the/e/path/path2/path3/path4/directory, $ editor = 3.

7. Prompt information function 2 (direct prompt content)
Syntax: printerror2 ($ error, $ gotourl, $ ecms, $ noautourl)
Note:
$ error: the information is displayed directly.
$ gotourl: the prompt information is redirected to the link address
$ ecms: 0 indicates the default prompt information mode, and 9 indicates the pop-up prompt information mode (alert mode ). This parameter can be omitted. The default value is 0.
$ noautourl: 0 indicates the automatic redirect page, and 1 indicates the automatic redirect page. This parameter can be omitted. The default value is 0.
example:
printerror2 ('add', 'HTTP: // www.phome.net '), the prompt message is "added" and is directed to the Empire website.
Note:
This function does not need to be combined with other variables, it can be used at any directory level. Language Pack variables are not supported.

8. Set the system cookie Variable Function
Syntax:Esetcookie ($ var, $ Val, $ life, $ ecms)
Note:
$ Var: variable name
$ VAL: variable value
$ Life: the cookie validity period, in seconds. 0 indicates that the cookie is not saved. This parameter can be omitted. It is not saved by default.
$ Ecms: 0 indicates the foreground cookie variable, and 1 indicates the background cookie variable. This parameter can be omitted. The default value is 0.
Example:
Esetcookie ('mybody', 'authorization'), defines the foreground "Cookie prefix + mybody" variable, and the variable content is "Empire"
Esetcookie ('mybody', 'authorization',), defines the backend "Cookie prefix + mybody" variable, and the variable content is "Empire"
Additional instructions:
The cookie function adds the cookie prefix to the variable name. You can also use the setcookie of PHP to define the cookie.

9. Obtain the system cookie Variable Function
Syntax:Getcvar ($ var, $ ecms)
Note:
$ Var: variable name
$ Ecms: 0 indicates the foreground cookie variable, and 1 indicates the background cookie variable. This parameter can be omitted. The default value is 0.
Example:
Getcvar ('mlusername') to obtain the username of the front-end login Member
Getcvar ('loginusername', 1), get the username of the background login Administrator
Additional instructions:
The cookie function is used to obtain the variable name with the cookie prefix. You can also use the $ _ cookie ['variable name'] of PHP to obtain the variable name.

10. Obtain the IP address Function
Syntax:Egetip ()
Example:
<? PHP
$ IP = egetip ();
Echo $ IP;
?>

11. Paging function for dynamic page display
Syntax:Page1 ($ num, $ line, $ page_line, $ start, $ page, $ search)
Note:
$ Num: Total number of records
$ Line: number of entries displayed per page
$ Page_line: Number of pagination links per page
$ Start: preset variable. Set it to 0.
$ Page: Current page number (0 indicates the start page number)
$ Search: additional link Parameters

12. Obtain the column name and column alias using the column ID:
Topic name: <? = $ Class_r [Topic id] ['classname']?>
Column alias: <? = $ Class_r [Topic id] ['bname']?>

 

=================== Introduction to calling PHP functions by the Emperor CMS ====================

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.