1.首页提取指定文章全部内容:
{dede:arclist idlist='38'}
<p>[field:title function='(strlen("@me")>20 ? cn_substr("@me",34)."..." : "@me")' /]</p>
<div class="break_line"></div>
<div class="_black"></div>
<div class="areaL_welcome_content">[field:id runphp='yes'] $aid = @me; $row = $GLOBALS['dsql']->GetOne("Select body From `dede_addonarticle` where aid='$aid' "); @me = "{$row['body']}";[/field:id]
</div>
{/dede:arclist}
2.提取自定栏目
{dede:channelartlist row=12 typeid='28,7,20'}//typeid 指定的是最顶层的id
<li><a href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a></li>
{/dede:channelartlist}
3.提取指定栏目下文章列表信息
arclist 自增长字段 调用 [field:global.autoindex/]
{dede:arclist titlelen='21' row='2' typeid='13' orderby='new' limit='2,2'}
[field:global.autoindex/]
<li id="header_R_C_2"><a href="[field:arcurl /]">[field:title function='(strlen("@me")>20 ? cn_substr("@me",34)."..." : "@me")' /]</a></li>
{/dede:arclist}
4.提取指定信息
{dede:type typeid='11'}<a href="[field:typelink/]">Hot News</a>{/dede:type}
5.前台页面标签内调用phpsql查询
[field:id runphp='yes'] $aid = @me; $row = $GLOBALS['dsql']->GetOne("Select body From `dede_addonarticle` where aid='$aid' "); @me = "{$row['body']}";[/field:id]
6.限制标题长度 超出部分采用...
[field:title function='(strlen("@me")>20 ? cn_substr("@me",20)."..." : "@me")' /]
7.获取指定栏目下的内容列表
{dede:arclist row='12' typeid='13'}
<li><a href="[field:arcurl/]"><span class="_font_weight1">[field:title function='(strlen("@me")>25 ? cn_substr("@me",25)."..." : "@me")'/] [field:pubdate function="MyDate('m-d',@me)"/]</span>
<br />
[field:info function='(strlen("@me")>125 ? cn_substr("@me",125)."..." : "@me")'/]</a></li>
{/dede:arclist}
注:[field:arcurl/] 文章链接 [field:typeurl/] 栏目链接 field:title 文章名称 field:typename 栏目名称
8.获取指定栏目下子栏目列表
{dede:channelartlist typeid='4,7,11,28'}
<div class="area1">
<p><a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a></p>
<div class="areaText1">
<ul>
{dede:channel type='son' row='8'}
<li><a href="[field:typeurl/]">[field:typename function='(strlen("@me")>25 ? cn_substr("@me",25)."..." : "@me")'/]</a></li>
{/dede:channel}
</ul>
</div>
</div>
{/dede:channelartlist}
9.如何调用当前栏目的上级栏目名称
网站需要在栏目列表页或内容页调用上级栏目的名称,也就是在列表或内容模板调用当前栏目的父栏目。方法如下,把以下代码插入到要显示DEDE系统父栏目的地方即可。
{dede:type}
[field:id runphp=yes]
$tsql = new DedeSql(false);
$typelink2 = '';
$tsql->SetQuery("Select i.typedir,i.typename From dede_arctype t left join dede_arctype i on i.id=t.reid wheret.id='@me'");
$tsql->Execute('t');
while($row = $tsql->GetArray('t',MYSQL_ASSOC))
{
$typelink2 .= $row['typename'];
}
@me=$typelink2;
[/field:id]
{/dede:type}
10.在列表页和内容页调用顶级栏目名称方法
{dede:field.typeid runphp='yes' function="GetTopid(@me)"}
$dsql = new DedeSql(false);
$a="SELECT typename FROM dede_arctype where id=@me";
$arcRow = $dsql->GetOne($a);
@me=$arcRow[typename];{/dede:field.typeid}
11.【LOOP 标记】
功能说明:用于调用任意表的数据,一般用于调用论坛贴子之类的操作
适用范围:所有模板
(1) 基本语法
{dede:loop table=' sort='' row='' if=''}
底层模板
{/dede:loop}
(2) 属性
[1] table 表示查询的数据表
[2] sort 用于排序的字段
[3] row 返回结果的条数
[4] if 查询条件
(3)底层模板变量
这个标记的底层模板变量即是被查询表的所有字段
例:获取Phpwind论坛的最新主题贴子
{dede:loop table='pw_threads' sort='tid' row='4' if='fid=10'}
<li> <a href="../read.php?tid=[field:tid/]">[field:subject function="cn_substr('@me',28)"/]
</a> </li>{/dede:loop}
12. 根据某个的参数用sql查询另外的参数
{dede:field name='position' runphp='yes'}
$tc=" > ";
$tf=split($tc,@me);
$para=trim($tf[1]);
$dbsql = $GLOBALS['dsql']->GetOne("Select normbody From `dede_myad` where tagname='english' ");
@me =$dbsql['normbody'];
echo @me;
{/dede:field}
13.调用tagname
{dede:field name='id' runphp='yes'}
$dsql = new DedeSql(false);
$sql = "select tag from dede_tagindex where id='".@me."' ";
$tagRow = $dsql->GetOne($sql);
@me=$tagRow['tag'];{/dede:field}
function getTagNameById($id)
{
global $dsql;
$sql = "select tid from dede_tagindex where id='$id' ";
if ($tagRow = $dsql->GetOne($sql)){
$tagname=$tagRow['tag'];
}
return $tagname;
}
14,.//调用栏目
function getAllRow($islor)
{
global $dsql;
$query = "SELECT * FROM `dede_arctype` where ".$islor."=1 and topid=0 and id<>1 and ishidden<>1 order by sortrank";
$dsql->Execute('allrow',$query);
while($row = $dsql->GetArray('allrow'))
{
if ($row['islist']=='0')
{
$div.="<h2 class='title_box'>" .$row['typename'] . "</h2><div class='colcontent'>" .$row['content']."</div>";
}else{
$topid=$row['id'];
$div2=getsonRow($topid,$islor);
$div .= "<h2 class='title_box'>" .$row['typename'] . "</h2>" . $div2;
}
}
return $div;
} function getsonRow($topid,$islor)
{
global $dsql;
$query = "SELECT * FROM `dede_arctype` where ".$islor."=1 and reid=$topid and ishidden<>1 order by sortrank";
$dsql->Execute('sonrow',$query);
while($row = $dsql->GetArray('sonrow'))
{
$reid=$row['id'];
$div3=getgrandsonRow($reid,$islor);
$path=$row['typedir'];
$path=str_replace("{cmspath}","",$path);
if ($path=="/")
{
$path=$path.$row['defaultname'];
}
else
{
$path=$path."/".$row['defaultname'];
}
$div2 .= "<li><a href='".$path."'>" .$row['typename'] . "</a>".$div3."</li>";
}
$div2="<ul class='left_menu'>".$div2;
$div2=$div2."</ul>";
return $div2;
}
function getgrandsonRow($reid,$islor)
{
global $dsql;
$query = "SELECT * FROM `dede_arctype` where ".$islor."=1 and reid=$reid and ishidden<>1 order by sortrank";
$dsql->Execute('grandsonrow',$query);
while($row = $dsql->GetArray('grandsonrow'))
{
$path=$row['typedir'];
$path=str_replace("{cmspath}","",$path);
if ($path=="/")
{
$path=$path.$row['defaultname'];
}
else
{
$path=$path."/".$row['defaultname'];
}
$div3 .= "<div class='sp'><a href='".$path."'>".$row['typename'] . "</a></div>";
}
return $div3;
}
15./*根据栏目ID返回栏目名称
*$id 栏目id
*$type 0 父栏目链接 1 子栏目链接
*$divid 输出格式<div id="$divid"><a title='typename' href='typeurl'>typename</a></div>
*/
function getColByID($ID,$type,$divid)
{
global $dsql;
if ($type==0){
//echo "0"."<br/>";
//父栏目链接
$query="select * from dede_arctype where id=(select topid from dede_arctype where id = '".$ID."') and ishidden <>1";
$row = $dsql->GetOne($query);
//$ReturnURL = GetTypeUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['siteurl']);
//echo $ReturnURL."<br/>";
$path=$row['typedir'];
$path=str_replace("{cmspath}","",$path);
if ($path=="/")
{
$path=$path.$row['defaultname'];
}
else
{
$path=$path."/".$row['defaultname'];
}
$ReturnURL="<a href='$path' title='".$row['typename']."'>".$row['typename']."</a>";
return $ReturnURL;
}
if ($type==1){
//echo "1"."<br/>";
//子栏目链接
$query="SELECT * FROM `dede_arctype` where reid=$ID and ishidden<>1 order by sortrank";
$dsql->Execute('sontype',$query);
//echo "$query<br/>";
while($row = $dsql->GetArray('sontype')){
//echo "$row['typeid']<br/>";
//$ReturnURL = GetTypeUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['siteurl']);
$path=$row['typedir'];
$path=str_replace("{cmspath}","",$path);
if ($path=="/")
{
$path=$path.$row['defaultname'];
}
else
{
$path=$path."/".$row['defaultname'];
}
$ReturnURL="<a href='$path' title='".$row['typename']."'>".$row['typename']."</a>";
$div .="<div id='".$divid.$row['id']."' class='$divid'>".$ReturnURL."</div>";
//echo $row['typename']."<br/>";
}
//echo $div."<br/>";
return $div;
}
}