我们可以看一个示例标签: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;
}
?>
$revalue = 'Hello Word!';
$revalue .="
Row:".$row.";TitleLen:".$titlelen;
这样我们可以看到,这个属性已经被创建变量并且赋值了。 接下来我们可以再进一步去修改这个标签。
function lib_writerarc(&$ctag,&$refObj)
$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();
}
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;
}
?>
{dede:writerarc row='10' titlelen='6'}
[field:title/]
{/dede:writerarc}
以上就是织梦DEDECMS扩展标签演示实例。现在理想已破碎,心理充满不甘和悔恨,好想把一切归零重新选一次,面对众人的不理解与嘲讽,好想去一个谁也不认识我的地方重新开始。更多关于织梦DEDECMS扩展标签演示实例请关注haodaima.com其它相关文章!