runphp='yes'在循环中的应用。
代码如下 | 复制代码 |
{dede:arclist row=14 titlelen=32 noflag='h'} <li><a href="[field:arcurl/]">[field:title/]</a> [field:id runphp='yes'] if(@me==5){ @me='选中'; }else{ @me='没选中'; } [/field:id] |
那么我们再来一些更高级的runphp=yes标签中调用其他field值
例子
代码如下 | 复制代码 |
{dede:php}$GLOBALS['xxoo']=$refObj->Fields['fieldname']{/dede:php} |
即,先开一个PHP的标签,把想赋的值替换给global变量。然后在另外的运行中将field值赋值给他。
如果是内容页使用以下代码:
代码如下 | 复制代码 |
{dede:field.id runphp='yes'} |
另一种使用方法:
{dede:field.id runphp=yes}
global $dsql;
$url="/";
$html=".html";
$sql1 = "SELECT id,typedir,sitepath,siteurl FROM dede_arctype where reid=3 and typename in(select typename from dede_arctype where id=".@me.")";
$dsql->execute('a',$sql1);
$row1=$dsql->getobject('a');
$url1=str_replace($row1->sitepath,"",$row1->typedir);
$siteurl=$row1->siteurl;
$sql2="select id,title,description,litpic from dede_archives where typeid=".$row1->id;
$dsql->execute('b',$sql2);
$rows=$dsql->GetTotalRow('b');
while($arr = $dsql->GetArray('b'))
{
$aa.= "<li>
<div class='zj_pic'><img src='http://ainaiyou.blog.163.com/blog/{$arr['litpic']}' height='136' width='112' /></div>
<div class='zj_detail'>
<h3> 姓名:{$arr['title']}</a></h3><p>{$arr['description']}... [<A href="http://www.ithov.net/.$siteurl.$url1.$url." {$arr['id']}".$html.">详细</A>]</p>
</div>
</li>";
}
@me=$aa;
{/dede:field.id}
{dede:field.id runphp=yes}
global $dsql;
$sql1="select id,typedir from dede_arctype where topid=0 and typename in(select typename from dede_arctype where id in(select typeid from dede_archives where id=".@me."))";
$dsql->execute('a',$sql1);
$row1=$dsql->getobject('a');
$sql2="select id,typedir,siteurl from dede_arctype where typename='媒体报道' and reid=".$row1->id;
$dsql->execute('b',$sql2);
$row2=$dsql->getobject('b');
$mtbd=str_replace("$row1->typedir","",$row2->typedir);
$siteurl=$row2->siteurl;
$url="/";
$html=".html";
$sql3="select * from dede_archives where typeid=".$row2->id;
$dsql->execute('c',$sql3);
$pub=array();
$rows=$dsql->GetTotalRow('c');
while($arr = $dsql->GetArray('c'))
{
$arr1['pubdate'].=Mydate('y-m-d',$arr['pubdate']).".";
$arr2['title'].=$arr['title'].".";
$arr3['id'].=$arr['id'].".";
}
@me="";
$title=explode(".",$arr2['title']);
$pubdate=explode(".",$arr1['pubdate']);
$id=explode(".",$arr3['id']);
for($x=0;$x<$rows;$x++)
{
@me.="<li><a href="http://www.ithov.net/.$siteurl.$mtbd.$url.$id[$x].$html.">".$title[$x].$pubdate[$x]."</a></li>";
}
{/dede:field.id}