【问题标题】:How are in theme templates created...? [closed]主题模板是如何创建的...? [关闭]
【发布时间】:2025-12-22 20:55:11
【问题描述】:

我希望我在这里问这个没问题,但我正在学习 PHP,我真的很想知道主题模板是如何创建的?

我说的是论坛软件中常见的模板,例如 vBulletin、XenForo、IP。 Board、MyBB、phpBB 等。它们使您无需打开核心文件即可编辑站点。

它们是用 PHP 创建的吗?或者他们是混合的???还是……?

【问题讨论】:

  • php 解析文件并用它们指定的命令、函数、字符串等替换机器标签
  • 对此没有唯一的答案。您提到的每个论坛应用程序都使用不同的主题化方法。

标签: php forum


【解决方案1】:

您可能正在讨论模板引擎, 即Smarty

一些示例代码:

include('Smarty.class.php');

// create object
$smarty = new Smarty;

// assign some content. This would typically come from
// a database or other source, but we'll use static
// values for the purpose of this example.
$smarty->assign('name', 'george smith');
$smarty->assign('address', '45th & Harris');

// display it
$smarty->display('index.tpl');

.tpl 文件

<html>
   <head>
      <title>Info</title>
   </head>
   <body>

      <pre>
         User Information:

        Name: {$name}
        Address: {$address}
      </pre>

   </body>
</html>

将 {$name} 和 {$address} 替换为 George smith 和 45th & Harris。

【讨论】: