Php WHMC在homepage.tpl上显示产品
我不知道如何在homepage.tpl中显示cart.php中的产品/服务。如果没有{debug}中显示的变量,我无法获取其他变量Php WHMC在homepage.tpl上显示产品,php,templates,smarty,whmcs,Php,Templates,Smarty,Whmcs,我不知道如何在homepage.tpl中显示cart.php中的产品/服务。如果没有{debug}中显示的变量,我无法获取其他变量 我找到了一种方法,直接在homepage.tpl中进行查询,但我认为这不是正确的方法。您需要通过Smarty变量传递产品/服务 在PHP文件中: global $smarty; $products = "Query goes here"; $smarty->assign("products", $products); 然后在.tpl文件中,假设它是一个数
我找到了一种方法,直接在homepage.tpl中进行查询,但我认为这不是正确的方法。您需要通过Smarty变量传递产品/服务 在PHP文件中:
global $smarty;
$products = "Query goes here";
$smarty->assign("products", $products);
然后在.tpl文件中,假设它是一个数组,您可以按如下方式访问它:
{foreach $products as $product}
<p>{$product.name}</p>
{/foreach}
{foreach$products as$product}
{$product.name}
{/foreach}
但这确实是基础知识。你可能需要考虑重新阅读模板的基本知识。