首页 >后端开发 >php教程 >在Dede中如何使用PHP的示例代码分享

在Dede中如何使用PHP的示例代码分享

黄舟
黄舟原创
2017-03-28 09:24:502490浏览

一、基本用法:

{dede:field.descriptionrunphp='yes'}
if(@me<>&#39;&#39; )
@me = &#39;<div class="intro">&#39;.@me.&#39;</div>&#39;;
{/dede:field.description}


{dede:field name=&#39;imgurls&#39; alt=&#39;图片输出区&#39;}
[field:pagestylerunphp=&#39;yes&#39;] @me= (@me==3 ? &#39;<li>&#39; : &#39;&#39;);[/field:pagestyle]
<a href=&#39;[field:linkurl/]&#39; [field:pagestyle runphp=&#39;yes&#39;] @me= (@me==3 ? &#39;class="pic"&#39; : &#39;&#39;); [/field:pagestyle]>
<img src=&#39;[field:imgsrc/]&#39; id=&#39;bigimg&#39; [field:imgwidth /] alt=&#39;[field:alttext /]&#39; border=&#39;0&#39; />
</a>
<a href=&#39;[field:linkurl/]&#39; [field:pagestyle runphp=&#39;yes&#39;]@me = (@me==3 ? &#39;class="title"&#39; : &#39;&#39;);[/field:pagestyle]>
[field:title /]
</a>
[field:pagestyle runphp=&#39;yes&#39;] @me = (@me==3 ? &#39;</li>&#39; : &#39;&#39;); [/field:pagestyle]
{/dede:field}

二、高级用法:

1、dede后台->系统->系统设置->系统基本参数->其它选项->把“模板引擎禁用标签”中的"php"标签去掉,保存

2、使用:

{dede:php}
echo &#39;php&#39;;
{/dede:php}

{dede:php}
$result = mysql_query("select * from bbs_forum_forum t1 left join bbs_forum_forumfield t2 on t1.fid=t2.fid where status=1 and 
type=&#39;forum&#39; order by t1.displayorder asc");
while($row = mysql_fetch_assoc($result)){
     echo &#39;<table cellpadding="0" cellspacing="0" width="100%" border="0" class="pbw_bbsTable">&#39;;
     echo &#39;<tr>&#39;;
     echo &#39;<td width="64">&#39;;
     echo &#39;<a href="/bbs/forum.php?mod=forumdisplay&fid=&#39;.$row[&#39;fid&#39;].&#39;">
     <img src="/bbs/data/attachment/common/&#39;.$row[&#39;icon&#39;].&#39;" width="46" height="46" style="border:1px solid #000;" /></a>&#39;;
     echo &#39;</td>&#39;;
     echo &#39;<td width="465">&#39;;
     echo &#39;<div class="pbw_bbsTitle"><a href="/bbs/forum.php?mod=forumdisplay&fid=&#39;.$row[&#39;fid&#39;].&#39;">&#39;.$row[&#39;name&#39;].&#39;</a><span>(&#39;.$row[&#39;threads&#39;].&#39;)</span></div>&#39;;
     echo &#39;<div class="pbw_bbsBrief">&#39;.$row[&#39;description&#39;].&#39;</div>&#39;;
     echo &#39;<div style="color:red;">&#39;.$row[&#39;rules&#39;].&#39;</div>&#39;;
     $moderators = explode("    ", $row[&#39;moderators&#39;]);
     $moderators = implode(",", $moderators);
     echo &#39;<div class="pbw_bbsBanzhu">版主:&#39;.$moderators.&#39;</div>&#39;;
     echo &#39;</td>&#39;;
     echo &#39;<td width="90"> </td>&#39;;
     echo &#39;<td width="120" align="center">&#39;;
     echo $row[&#39;threads&#39;].&#39;/&#39;.$row[&#39;posts&#39;];
     echo &#39;</td>&#39;;
     echo &#39;<td>&#39;;
     $lastpost = explode("    ", $row[&#39;lastpost&#39;]);
     echo &#39;<a href="/bbs/forum.php?mod=viewthread&tid=&#39;.$lastpost[0].&#39;#lastpost">&#39;.$lastpost[1].&#39;</a>
     (<a href="/bbs/home.php?mod=space&username=&#39;.$lastpost[3].&#39;" style="color:#369">&#39;.$lastpost[3].&#39;</a>)<br />&#39;;
     echo date("Y-m-d H:i:s", $lastpost[2]);
     echo &#39;</td>&#39;;
     echo &#39;</tr>&#39;;
     echo &#39;</table>&#39;;
}
{/dede:php}

以上是在Dede中如何使用PHP的示例代码分享的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn