是否可以在smarty中将数组作为参数传递?这是我的代码。感谢
{foreach from = $diamond_all key = k item = value}
<tr class="gradeA" id="diamond_id_">
<td>{$value.Shape}</td>
<td>{$value.CaratPerPrice}</td>
<td>Add Ring</td>
{$value.ID}">Certificate</a></td>
<td>{$value.Weight}</td>
<td>{$value.Cut}</td>
<td>{$value.Color}</td>
<td>{$value.Clarity}</td>
<td>{$value.Price}</td>
<td> <a class="view_details cboxElement" href="array.php?name=PASS_ARRAY">{$value.ID} View Details</a></td>
</tr>
{/foreach}
EDIT 我有像php这样的数组。然后我用smarty打印这个数组。
[0] => Array
(
[ID] => 30237638
[Shape] => Round
[Weight] => 1.000
[Cut] => Good
[Color] => F
[Clarity] => VS2
[Price] => 5282.48
[Company] =>
[VendorStockNumber] => 92102001
[Symmetry] => Very Good
[Polish] => Excellent
[Depth] => 65.1
[Table] => 57.00
[MeasLength] => 6.20
[MeasWidth] => 6.24
[MeasDepth] => 4.05
[GirdleSizeMin] => Slightly Thick
[GirdleSizeMax] => Thick
[Culet] => None
[Fluorescence] => None
[CaratPerPrice] => 5282.48
[CertificateNumber] => 2131048944
)
答案 0 :(得分:0)
我建议使用PHP http_build_query
。您可以在PHP中生成详细信息链接并在Smarty中进行分配(或者如果您要做很多事情,可以编写一个Smarty插件来调用http_build_query
。Documentation)
PHP:
$diamond = array(
'ID' => 30237638,
'Shape' => 'Round',
'Weight' => 1.000,
'Cut' => 'Good',
'Color' => 'F',
'Clarity' => 'VS2',
'Price' => 5282.48,
'Company' => '',
'VendorStockNumber' => 92102001,
'Symmetry' => 'Very Good',
'Polish' => 'Excellent',
'Depth' => 65.1,
'Table' => 57.00,
'MeasLength' => 6.20,
'MeasWidth' => 6.24,
'MeasDepth' => 4.05,
'GirdleSizeMin' => 'Slightly Thick',
'GirdleSizeMax' => 'Thick',
'Culet' => 'None',
'Fluorescence' => 'None',
'CaratPerPrice' => 5282.48,
'CertificateNumber' => 2131048944,
);
$smarty->assign('details_href', 'array.php?' . http_build_query($diamond));
?>
模板:
<a class="view_details cboxElement" href="{$details_href}">{$value.ID} View Details</a>