当前位置:Gxlcms > PHP教程 > 在Dede中如何使用PHP的示例代码分享

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

时间:2021-07-01 10:21:17 帮助过:25人阅读

一、基本用法:

  1. {dede:field.descriptionrunphp='yes'}
  2. if(@me<>'' )
  3. @me = '<div class="intro">'.@me.'</div>';
  4. {/dede:field.description}
  5. {dede:field name='imgurls' alt='图片
输出区'} [field:pagestylerunphp='yes'] @me= (@me==3 ? '<li>' : '');[/field:pagestyle] <a href='[field:linkurl/]' [field:pagestyle runphp='yes'] @me= (@me==3 ? 'class="pic"' : ''); [/field:pagestyle]> <img src='[field:imgsrc/]' id='bigimg' [field:imgwidth /] alt='[field:alttext /]' border='0' /> </a> <a href='[field:linkurl/]' [field:pagestyle runphp='yes']@me = (@me==3 ? 'class="title"' : '');[/field:pagestyle]> [field:title /] </a> [field:pagestyle runphp='yes'] @me = (@me==3 ? '</li>' : ''); [/field:pagestyle] {/dede:field}

二、高级用法:

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

2、使用:

  1. {dede:php}
  2. echo 'php';
  3. {/dede:php}
  4. {dede:php}
  5. $result = mysql_query("select * from bbs_forum_forum t1 left join bbs_forum_forumfield t2 on t1.fid=t2.fid where status=1 and
  6. type='forum' order by t1.displayorder asc");
  7. while($row = mysql_fetch_assoc($result)){
  8. echo '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="pbw_bbsTable">';
  9. echo '<tr>';
  10. echo '<td width="64">';
  11. echo '<a href="/bbs/forum.php?mod=forumdisplay&fid='.$row['fid'].'">
  12. <img src="/bbs/data/attachment/common/'.$row['icon'].'" width="46" height="46" style="border:1px solid #000;" /></a>';
  13. echo '</td>';
  14. echo '<td width="465">';
  15. echo '<div class="pbw_bbsTitle"><a href="/bbs/forum.php?mod=forumdisplay&fid='.$row['fid'].'">'.$row['name'].'</a><span>('.$row['threads'].')</span></div>';
  16. echo '<div class="pbw_bbsBrief">'.$row['description'].'</div>';
  17. echo '<div style="color:red;">'.$row['rules'].'</div>';
  18. $moderators = explode(" ", $row['moderators']);
  19. $moderators = implode(",", $moderators);
  20. echo '<div class="pbw_bbsBanzhu">版主:'.$moderators.'</div>';
  21. echo '</td>';
  22. echo '<td width="90">&nbsp;</td>';
  23. echo '<td width="120" align="center">';
  24. echo $row['threads'].'/'.$row['posts'];
  25. echo '</td>';
  26. echo '<td>';
  27. $lastpost = explode(" ", $row['lastpost']);
  28. echo '<a href="/bbs/forum.php?mod=viewthread&tid='.$lastpost[0].'#lastpost">'.$lastpost[1].'</a>
  29. (<a href="/bbs/home.php?mod=space&username='.$lastpost[3].'" style="color:#369">'.$lastpost[3].'</a>)<br />';
  30. echo date("Y-m-d H:i:s", $lastpost[2]);
  31. echo '</td>';
  32. echo '</tr>';
  33. echo '</table>';
  34. }
  35. {/dede:php}

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

人气教程排行