我想将此php连接到tpl。
但是当我尝试运行时它给了我致命的错误。
我在 php 中添加了 smarty 以在 tpl 文件中显示这些数据,但仍然有问题。
<?php
include('developer.php');
if( $xml = simplexml_load_file(url))
{
foreach($xml->campaign as $campaigns)
{
$camp_name = $campaignsl->name;
$camp_dec= $campaigns->description;
$camp_payout= $campaigns->payout;
$camp_url= $campaigns->url;
$smarty->assign( 'camp_name', $camp_name);
$smarty->assign( 'camp_dec', $camp_dec);
$smarty->assign( 'camp_payout', $camp_payout);
$smarty->assign( 'camp_url', $camp_url);
$smarty->display('link.tpl');
}
}
?>
这是 tpl 文件 (link.tpl)。
<table width="100%" class="widget-tbl">
<tr class="titles">
<td align="center">Name</td>
<td align="center">Description</td>
<td align="center">amount</td>
<td align="center">Link</td>
</tr>
<tbody id="tablelist">
{foreach item=item from=$campaigns}
<tr>
<td align="center">{$camp_name}</td>
<td align="center">{$camp_dec}</td>
<td align="center">{$camp_payout}</td>
<td align="center">{$camp_url}</td>
</tr>
{/foreach}
</tbody>