[英]PHPBB template comment conditional
I see in PHPBB they use conditional statements inside their HTML, or XHTML; 我在PHPBB中看到他们在HTML或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. 这将非常有用,并清理了大量代码。
I would take a look at the PHPBB source code and find the files that parse these comments. 我将看一下PHPBB源代码,并找到解析这些注释的文件。 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 http://area51.phpbb.com/docs/coding-guidelines.html#templates
To have PHP code inside your template you need to use the special PHP "comment condition". 要在模板中包含PHP代码,您需要使用特殊的PHP“注释条件”。
<!-- PHP -->
// your code goes here
<!-- ENDPHP -->
PHP may work: PHP可能有效:
<?php if ($moderator) { ?>
<p class="moderators">
<?php } ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.