You are here: Re: [SMARTY] Referencing complex associative array « Smarty Templates Posts « IT news, forums, messages
Re: [SMARTY] Referencing complex associative array

Posted by Abdul-Wahid Paterson on 04/28/05 11:48

It is a bit hard to read the structure...but i think...


$result->ITEMS is the array with your news items
so

{section name=news loop=$result.ITEMS}
<tr>
<td>
{$result.ITEMS.[news].LINK}
</td>
</tr>
{/section}

But I am a bit confused from your email what is $result and what is $news.

Abdul-Wahid

This would would loop through the news items.
On 4/28/05, Roger Thomas <sniper@home.net.my> wrote:
> Hi,
> I parsed an XML file and pushed the results into an array. My question is, when I assign this array, $result, to Smarty, how do I reference it ?
>
> I have something like:
> {section name=feed loop=$news}
> <tr>
> <td>
> {$news[feed].COPYRIGHT}
> </td>
> </tr>
> {/section}
>
> How do I reference, say, the LINK under ITEMS ? Please advise.
>
> If I do a var_dump on $result, it looks like this:
>
> array(10) {
> ["TITLE"]=>
> string(39) "BBC News | News Front Page | UK Edition"
> ["LINK"]=>
> string(47) "http://news.bbc.co.uk/go/rss/-/1/hi/default.stm"
> ["DESCRIPTION"]=>
> string(33) "Updated every minute of every day"
> ["LANGUAGE"]=>
> string(5) "en-gb"
> ["LASTBUILDDATE"]=>
> string(27) "Wed, 27 Apr 05 23:59:27 GMT"
> ["COPYRIGHT"]=>
> string(92) "Copyright: (C) British Broadcasting Corporation, http://news.bbc.co.uk/1/hi/help/3281849.stm"
> ["DOCS"]=>
> string(33) "http://www.bbc.co.uk/syndication/"
> ["TTL"]=>
> string(2) "15"
> ["IMAGE"]=>
> array(3) {
> ["TITLE"]=>
> string(8) "BBC News"
> ["URL"]=>
> string(56) "http://news.bbc.co.uk/nol/shared/img/bbc_news_120x60.gif"
> ["LINK"]=>
> string(21) "http://news.bbc.co.uk"
> }
> ["ITEMS"]=>
> array(5) {
> [0]=>
> array(5) {
> ["TITLE"]=>
> string(31) "Early Iraq legal opinion leaked"
> ["DESCRIPTION"]=>
> string(115) "The attorney general doubted the Iraq war would be legal without a new resolution from the UN, leaked advice shows."
> ["LINK"]=>
> string(79) "http://news.bbc.co.uk/go/rss/-/1/hi/uk_politics/vote_2005/frontpage/4491105.stm"
> ["GUID"]=>
> string(70) "http://news.bbc.co.uk/1/hi/uk_politics/vote_2005/frontpage/4491105.stm"
> ["PUBDATE"]=>
> string(27) "Wed, 27 Apr 05 22:32:09 GMT"
> }
> [1]=>
> array(5) {
> ["TITLE"]=>
> string(32) "Man arrested over Abigail attack"
> ["DESCRIPTION"]=>
> string(96) "A 25-year-old man has been arrested by detectives hunting the man who stabbed Abigail Witchalls."
> ["LINK"]=>
> string(73) "http://news.bbc.co.uk/go/rss/-/1/hi/england/southern_counties/4492119.stm"
> ["GUID"]=>
> string(64) "http://news.bbc.co.uk/1/hi/england/southern_counties/4492119.stm"
> ["PUBDATE"]=>
> string(27) "Wed, 27 Apr 05 23:53:19 GMT"
> }
> [2]=>
> array(5) {
> ["TITLE"]=>
> string(32) "Jackson's ex-wife in witness box"
> ["DESCRIPTION"]=>
> string(122) "Prosecutors in Michael Jackson's child abuse trial begin questioning the star's ex-wife and mother of two of his children."
> ["LINK"]=>
> string(67) "http://news.bbc.co.uk/go/rss/-/1/hi/entertainment/music/4490259.stm"
> ["GUID"]=>
> string(58) "http://news.bbc.co.uk/1/hi/entertainment/music/4490259.stm"
> ["PUBDATE"]=>
> string(27) "Wed, 27 Apr 05 21:58:53 GMT"
> }
> [3]=>
> array(5) {
> ["TITLE"]=>
> string(33) "US terror charge Briton convicted"
> ["DESCRIPTION"]=>
> string(112) "A British man is found guilty of attempting to support terrorism after trying to sell a missile to an FBI agent."
> ["LINK"]=>
> string(50) "http://news.bbc.co.uk/go/rss/-/1/hi/uk/4491181.stm"
> ["GUID"]=>
> string(41) "http://news.bbc.co.uk/1/hi/uk/4491181.stm"
> ["PUBDATE"]=>
> string(27) "Wed, 27 Apr 05 20:07:48 GMT"
> }
> [4]=>
> array(5) {
> ["TITLE"]=>
> string(28) "Airbus A380 completes flight"
> ["DESCRIPTION"]=>
> string(103) "The world's largest passenger plane, the Airbus A380, lands safely, having completed its maiden flight."
> ["LINK"]=>
> string(56) "http://news.bbc.co.uk/go/rss/-/1/hi/business/4488361.stm"
> ["GUID"]=>
> string(47) "http://news.bbc.co.uk/1/hi/business/4488361.stm"
> ["PUBDATE"]=>
> string(27) "Wed, 27 Apr 05 17:32:10 GMT"
> }
> }
> }
>
> --
> Roger
>
> ---------------------------------------------------
> Sign Up for free Email at http://ureg.home.net.my/
> ---------------------------------------------------
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация