Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Array problem

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
noobie-php
Smarty n00b


Joined: 23 Nov 2011
Posts: 4

PostPosted: Wed Nov 23, 2011 9:16 am    Post subject: Array problem Reply with quote

there is a problem here with this array of mine i want to access the value of thumbnail. this is what i am following but i get '1' as out put
this is my current code.

<div id="display_image">
{foreach from=$products_images item=photo name=photo}
{foreach from=$photo item=thumbnail name=thumbnail}
{$thumbnail|print_r}
<a href="{$smarty.const.RL_URL_HOME}files/{$photo.thumbnail}">
<img src="{$smarty.const.RL_URL_HOME}files/{$thumbnail}" width="87" height="65" style="margin:3px;" /> </a>
{/foreach}
{/foreach}

</div>

this is what i get whent i dump values
Array ( [ID] => 2 [Listing_ID] => 2 [POSITION] => 1 [Photo] => listing_photo2_10162615801320121462.jpg [Thumbnail] => listing_thumbnail2_2412324231320121462.jpg [Original] => listing_orig2_9314412411320121462.jpg [Description] => car [TYPE] => sale [STATUS] => active [Kind_ID] => 1 [Account_ID] => 1 [Plan_ID] => 1 [Pay_date] => 2011-11-01 09:23:53 [Featured_ID] => 1 [Featured_date] => 0000-00-00 00:00:00 [Last_show] => 0000-00-00 00:00:00 [Crossed] => [Shows] => 2 [DATE] => 2011-11-01 09:23:53 [Rating] => 0 [Rating_votes] => 0 [Cron] => 0 [Cron_notified] => 0 [Cron_featured] => 0 [categories] => [headline] => Car [price] => 1|dollar [description] => this IS a car [CONDITION] => 1 [title] => [lf_site_url] => [description_add] => [contact_number] => ) Array ( [ID] => 3 [Listing_ID] => 3 [POSITION] => 1 [Photo] => listing_photo3_8394210431320195062.jpg [Thumbnail] => listing_thumbnail3_6168937301320195062.jpg [Original] => listing_orig3_16717643711320195062.jpg [Description] => [TYPE] => sale [STATUS] => active [Kind_ID] => 1 [Account_ID] => 8 [Plan_ID] => 1 [Pay_date] => 2011-11-16 07:50:58 [Featured_ID] => 9 [Featured_date] => 0000-00-00 00:00:00 [Last_show] => 0000-00-00 00:00:00 [Crossed] => [Shows] => 6 [DATE] => 2011-11-02 05:50:45 [Rating] => 0 [Rating_votes] => 0 [Cron] => 0 [Cron_notified] => 0 [Cron_featured] => 0 [categories] => [headline] => Car Mart [price] => 100|dollar [description] => [CONDITION] => 1 [title] => [lf_site_url] => [description_add] => [contact_number] => )

i just cant access the value of thumbnails.

please correct or suggest an alternative to access values
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Nov 23, 2011 10:34 pm    Post subject: Reply with quote

Your provided dump belongs to which variable?
Back to top
View user's profile Send private message
noobie-php
Smarty n00b


Joined: 23 Nov 2011
Posts: 4

PostPosted: Thu Nov 24, 2011 6:36 am    Post subject: if you can see the code you will see dump variable Reply with quote

i provided dump for thumbnail i guess you missed it. Please have a look on it.
{$thumbnail|print_r}
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Nov 24, 2011 8:44 pm    Post subject: Reply with quote

What confused me was that $thumbnail does contain again the elements Photo and Thumbnail.

I now think you are looking for
Code:
<div id="display_image">
{foreach from=$products_images item=photo name=photo}
{foreach from=$photo item=thumbnail name=thumbnail}
{$thumbnail|print_r}
<a href="{$smarty.const.RL_URL_HOME}files/{$thumbnail.Photo}">
<img src="{$smarty.const.RL_URL_HOME}files/{$thumbnail.Thumbnail}" width="87" height="65" style="margin:3px;" /> </a>
{/foreach}
{/foreach}
Back to top
View user's profile Send private message
noobie-php
Smarty n00b


Joined: 23 Nov 2011
Posts: 4

PostPosted: Tue Nov 29, 2011 11:21 am    Post subject: thx man Reply with quote

thx man your code actually helped me solving my own code
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP