To use the template tag without compromising the readability of the document, dedecms, unlike other templates, sometimes directly inserts PHP or PHP-like code into the template to achieve real separation of templates and programs.
However, to make the program more scalable, dedecms allows the use of Function
For expansion, the function can be a system function or a custom function, but only used in two aspects:
1. template Tag:
For example: {Dede: field name = 'pubdate'
Function = getdatetimemk ('@ me ')/}
The actual returned result is the result after the getdatetimemk function is executed.
In general, the custom extension functions marked by the template are placed in:
Include/inc_functions.php
Or
Include/inc_functions.php
Include/inc_channel_unit_functions.php
2. Collection configuration fields:
For example: {Dede: Note field = 'title'
Value = '[Var: content]'
Function = test ('@ me ')}
{Dede: Match} <title> [Var: content] </title> {/Dede: Match}
{/Dede: note}
The result returned by this collection node is the result returned after the test function is executed.
Generally, the custom extension functions of the collection extension are placed in:
Include/pub_collection_functions.php
In the preceding example, @ me indicates the original value of the mark. If it is an int or floating point type, no quotation marks are allowed. The string must be enclosed by quotation marks.
Flexible use of extended functions allows you to make many random functions, but you do not need to change the source code of the system. For collection extensions, you can more flexibly process the collected original content.
The woven dream mark allows limited programming extensions.
Current System Time
{Dede: tagname runphp = 'yes'} @ me = date ("Y"); {/Dede: tagname}
Format:
{Dede: tagname runphp = 'yes '}
$ AAA = @ me;
@ Me =
"123456 ";
{/Dede: tagname}
@ Me indicates the value of this tag. Therefore, in-tag programming, ECHO and other statements cannot be used, and all return values can only be passed to @ me.
In addition, because the program code occupies the content of the underlying template innertext, you must use the default innertext only for the markup that needs to be programmed.
Filter out HTML code
{Dede: arclist sort = 'hot 'titlelen = 40 ROW = 8}
<Li> <a Title = "[field: title function = 'html2text (@ me) '/]" href = "[field: arcurl/]"> [field: title/] </a> </LI>
{/Dede: arclist}
{Dede: field name = 'description'
Function = 'html2text (@ me )'/}
{Dede: List
Imgwidth = '*'
Imgheight = '*'}
Width = "*"
Height = "*">
Modify includeinc_channel_unit_functions.php
Width = 80 align = left>
You can change the thumbnail size.
The thumbnail address before 5.1 is
120u10ml014147_lit.gif
5.1changed to lit_120u10ml014147.gif
Set [field: picname
Function = 'str _ Replace ("_ blank", "", @ me) '/]
Change to [field: picname
Function = 'str _ Replace ("comment _", "", @ me) '/]
Function = 'str _ Replace ("Homepage", "", html2text ("@ me "))'
In the product list, a value is processed by a function. Normally, a variable is like this:
[Field: typeid
Function = 'get _ linkshangpin (@ me, 3) '/]
[Field: pubdate
Function = 'strftime ("% m-% d", @ me) '/]
[Field: litpic
Function = "cklitimageview (@ me, 80)"/]
Modify includeinc_channel_unit_functions.php
Width = 80 align = left>
Function = 'cn _ substr ("@ me", 2). Take the screenshot on the left of this field.
What function is used to intercept the image from the right ..
I am using Dede to call the blog star image in the supersite blog.
Its image address is the directory corresponding to the UID.
For example, if the UID is 176, the corresponding member image may be/
76/photo_176.gif
If I use function = 'cn _ substr ("@ me", 2 ).
The intercepted uid is changed to 17...
How can I cut the right side to 76?
,
Function = substr ("@ me",-2)
Add verification code to comments using Dede's runphp function (optional)
First, add the following code to include/config_base.php:
Copy code
// Comment on whether to enable the verification code (0 No 1 Yes). If the verification code is changed, you must regenerate the article HTML.
$ Feedback_validate
= 1;
Then
Add the following code to the corresponding location of the Comment Form in/templets/default/article_article.htm,/templets/plus/feedback_templet.htm, and other places:
{Dede: PhP runphp = 'yes '}
If ($ feedback_validate ){
@ Me =
"<Tr>
<TD> Verification Code: </TD>
<TD> <input name = \ "Validate \" type = \ "text \" id = \ "Validate \"> </TD>
</Tr> ";
}
{/Dede: PhP}
Find the following code in/plus/feedback. php:
Else if ($ action = "send ")
{
Add the following content:
Session_start ();
If (empty ($ _ session ["s_validate"])
$ Svali =
"";
Else $ svali
= $ _ Session ["s_validate"];
If ($ feedback_validate
& Strtolower ($ vdcode )! = $ Svali
& $ Svali! = ""){
Showmsg ("Verification code error! ","-1 ");
Exit ();
In this way, the Comment verification code function can be implemented and the switch is optional.
In addition, you can add time and IP restrictions to comments.
{Dede: field name = 'keyword'
Runphp = 'yes'
}
If (! Empty (@ me )){
$ KWS =
Explode ('', @ me );
@ Me =
"";
Foreach ($ KWS
As $ K ){
@ Me. =
"<A class = 'tags' href = 'javascript: void (null) '> $ k </a> ";
}
// @ Me = str_replace ('+', '', trim (@ me ));
}
{/Dede: Field}