i trying rewrite rss feed parser php code smarty. smarty not work me somehow. can me out please?
<ul> <?php foreach ($feed['items'] $item): ?> <li> <a href="<?= $item['link']; ?>"><?= $item['title']; ?></a> </li> <?php endforeach; ?> </ul>
my smarty code updated: 12/07/13
{foreach name=aussen item=$feed.items from=$item} <li> <a href="{$item.link}">{$item.title}</a> </li> {/foreach}
there lot of issues smarty code. first, , foremost, should not have php logic , smarty formatting in same file. should assign smarty variables separately , call smarty formatting. if stick existing stuff, you'll need take account following:
syntax of
foreach
wrong - correct syntax{foreach from=$variable item=$loop_var}
php variables not automatically available in smarty - you'll need add smarty
{assign} directive combination of
{php}echo $php_var{/php}` php variable smarty.syntax
{php}$item['title']{/php}
invalid syntax php , result in syntax error.
on whole, approach flawed. smarty presentation (view) layer in mvc app - , you're trying combine 1 file. don't. if not sure how set application mvc, smarty not you.
Comments
Post a Comment