How to use the DEDECMS extension tag?
DDEECMS extension tag demonstration example
Recommended learning: DEMENCMS
We can look at a sample tag: demotag.lib .php,
if(!defined('DEDEINC')) { exit("Request Error!"); } function lib_demotag(&$ctag,&$refObj) { global $dsql,$envs; $attlist="row|12,titlelen|24"; FillAttsDefault($ctag->CAttribute->Items,$attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $revalue = ''; //------------------------------------------------------ $revalue = 'Hello Word!'; //------------------------------------------------------ return $revalue; } ?>
We will find that the tag works and our content is output.
$revalue = 'Hello Word!'; $revalue .=" Row:".$row.";TitleLen:".$titlelen;
So we can see that this attribute has been created as a variable and assigned a value.
Next we can further modify this label.
function lib_writerarc(&$ctag,&$refObj)
Next we can write query statements and related functions for underlying template processing
$revalue = ''; $innertext = $ctag->GetInnerText(); $ctp = new DedeTagParse(); $ctp->SetNameSpace('field', '[', ']'); $sql = "SELECT * FROM dede_archives WHERE writer='{$refObj->Fields['writer']}' limit 0, $row"; $dsql->Execute('me',$sql); while($rs = $dsql->GetArray('me')) { $rs['title'] = cn_substr($rs['title'], $titlelen); $ctp->LoadSource($innertext); foreach($ctp->CTags as $tagid=>$ctag) { if(!emptyempty($rs[strtolower($ctag->GetName())])) { $ctp->Assign($tagid,$rs[$ctag->GetName()]); } } $revalue .= $ctp->GetResult(); }
Finally return this value return $revalue;
The entire file content is as follows:
if(!defined('DEDEINC')) { exit("Request Error!"); } function lib_writerarc(&$ctag,&$refObj) { global $dsql,$envs; $attlist="row|12,titlelen|24"; FillAttsDefault($ctag->CAttribute->Items,$attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $revalue = ''; $innertext = $ctag->GetInnerText(); $ctp = new DedeTagParse(); $ctp->SetNameSpace('field', '[', ']'); $sql = "SELECT * FROM dede_archives WHERE writer='{$refObj->Fields['writer']}' limit 0, $row"; $dsql->Execute('me',$sql); while($rs = $dsql->GetArray('me')) { $rs['title'] = cn_substr($rs['title'], $titlelen); $ctp->LoadSource($innertext); foreach($ctp->CTags as $tagid=>$ctag) { if(!emptyempty($rs[strtolower($ctag->GetName())])) { $ctp->Assign($tagid,$rs[$ctag->GetName()]); } } $revalue .= $ctp->GetResult(); } return $revalue; } ?>
View and debug through dynamic browsing of the page?aid=3
{dede:writerarc row='10' titlelen='6'} [field:title/] {/dede:writerarc}
The above is the detailed content of How to use the DEDECMS extension tag. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.