我正忙于 Prestashop。不幸的是,我以前从未与 Smarty 合作过。我有以下问题:如何将 PHP 数组分配更改为 Smarty 数组,以及如何使用 Smarty 在模板中读出它?
$query="SELECT id_category, id_parent FROM ps_category ORDER BY id_category ASC, id_parent ASC";
$result = mysql_query($query);
while (list($hlc_id_category, $hlc_id_parent) = mysql_fetch_row($result))
{
$query="SELECT name, description FROM ps_category_lang WHERE id_category = '" . $hlc_id_category . "'";
$resultnaam = mysql_query($query);
list($hlc_categoryname, $hlc_description) = mysql_fetch_row($resultnaam);
if ($hlc_id_parent == 2)
{
$hlc_category_class = 'hoofdcategorie';
}
if ($hlc_id_parent > 2)
{
$hlc_category_class = 'hoofdcategorie';
}
$hlc_categories[] = array ('hlc_id_category' => $hlc_id_category, 'hlc_categoryname' => $hlc_categoryname, 'hlc_description' => $hlc_description);
}