PHPbb 传递参数或定义参数
aboutus.html 中的 {CONSTANT} 如何显示“Hello world”。我在 aboutus.php 定义的?
非常非常感谢。
aboutus.php - 我已经将 CONSTANT 定义为 hello world。
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
define("CONSTANT", "Hello world.");
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
if ($user->data['user_id'] == ANONYMOUS)
{
login_box('', $user->lang['LOGIN']);
}
page_header('Title Here');
$template->set_filenames(array(
'body' => 'aboutus_body.html',
));
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
aboutus_body.html - {CONSTANT} 如何显示“Hello World”。上面定义的?
<h2>About Us2</h2>
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<div class="content">
<p>
We were founded this year to bring you the best forum on the Internet!
We promise to do the following:
<ul>
<li>Provide new content</li>
<li>provide a friendly atmosphere</li>
<li>Provide an environment where you can have fun!</li>
</ul>
<p>{CONSTANT}</p>
</p>
</div>
<span class="corners-bottom"><span></span></span></div>
</div>
How can {CONSTANT} at the aboutus.html can display "Hello world." which i defined at aboutus.php ?
Many Many Thanks.
aboutus.php - I have define CONSTANT to hello world.
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
define("CONSTANT", "Hello world.");
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
if ($user->data['user_id'] == ANONYMOUS)
{
login_box('', $user->lang['LOGIN']);
}
page_header('Title Here');
$template->set_filenames(array(
'body' => 'aboutus_body.html',
));
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
aboutus_body.html - how can {CONSTANT} display "Hello World." that defined above?
<h2>About Us2</h2>
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<div class="content">
<p>
We were founded this year to bring you the best forum on the Internet!
We promise to do the following:
<ul>
<li>Provide new content</li>
<li>provide a friendly atmosphere</li>
<li>Provide an environment where you can have fun!</li>
</ul>
<p>{CONSTANT}</p>
</p>
</div>
<span class="corners-bottom"><span></span></span></div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试定义的模板变量不是传统的 PHP 常量。相反,使用模板类的 allocate_var()/assign_vars()/assign_block_vars() 方法将它们从 PHP 文件分配给模板。
例如:
请注意,模板变量必须大写,块名称必须小写。
然后,您可以像这样调用文件中的变量:
{CONSTANT}
对于一个块:
Template variables, as you are trying to define, are not traditional PHP Constants. Instead, they are assigned to the template from the PHP file using the template class's assign_var()/assign_vars()/assign_block_vars() methods.
For instance:
Note that template variables must be UPPERCASE, and block names must be lowercase.
You then call the variable in the file like so:
{CONSTANT}
For a block: