Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WHMC在homepage.tpl上显示产品_Php_Templates_Smarty_Whmcs - Fatal编程技术网

Php WHMC在homepage.tpl上显示产品

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中显示cart.php中的产品/服务。如果没有{debug}中显示的变量,我无法获取其他变量


我找到了一种方法,直接在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}
但这确实是基础知识。你可能需要考虑重新阅读模板的基本知识。