doudilin1225
2010-03-19 01:53
浏览 69
已采纳

PHPBB模板注释有条件

I see in PHPBB they use conditional statements inside their HTML, or XHTML; if you dont know what I mean here is a snippet:

<!-- IF MODERATORS -->
<p class="moderators"><!-- IF S_SINGLE_MODERATOR -->{L_MODERATOR}<!-- ELSE 

-->{L_MODERATORS}<!-- ENDIF -->: {MODERATORS}</p>
<!-- ENDIF -->
<!-- IF U_MCP -->
    <p class="linkmcp">[ <a href="{U_MCP}">{L_MCP}</a> ]</p>
<!-- ENDIF -->

Is there an explanation on how to implement this in my own site? It would be very useful and clean up a lot of code.

图片转代码服务由CSDN问答提供 功能建议

我在PHPBB中看到他们在HTML或XHTML中使用条件语句; 如果你不知道我的意思,这里有一个片段:

 &lt;! -  IF MODERATORS  - &gt; 
&lt; p class =“moderators”&gt;&lt;  ! - 如果S_SINGLE_MODERATOR  - &gt; {L_MODERATOR}&lt;! -  ELSE 
 
  - &gt; {L_MODERATORS}&lt;! -  ENDIF  - &gt;:{MODERATORS}&lt; / p&gt; 
&lt;  ;  -  ENDIF  - &gt; 
&lt;! -  IF U_MCP  - &gt; 
&lt; p class =“linkmcp”&gt; [&lt; a href =“{U_MCP}”&gt; {L_MCP}&lt;  ; / A&GT;  ]&lt; / p&gt; 
&lt;! -  ENDIF  - &gt; 
   
 
 

是否有关于如何在我自己的网站中实现此功能的说明? 这将是非常有用的,并清理了很多代码。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • douqudi5282 2010-03-19 03:23
    已采纳

    I would take a look at the PHPBB source code and find the files that parse these comments. There's probably a class for templates which you could reuse for your own projects.

    If it helps, documentation about the syntax is available at:

    http://area51.phpbb.com/docs/coding-guidelines.html#templates

    已采纳该答案
    打赏 评论
  • dtziv24262 2010-03-19 02:47

    PHP may work:

    <?php if ($moderator) { ?>
    <p class="moderators">
    <?php } ?>
    
    打赏 评论
  • douji1077 2013-01-16 10:52

    To have PHP code inside your template you need to use the special PHP "comment condition".

    <!-- PHP -->
    // your code goes here
    <!-- ENDPHP -->
    
    打赏 评论

相关推荐 更多相似问题