Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Array of Objects with 2d Arrays...uh what is happening?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
MaxPower
Smarty n00b


Joined: 22 Oct 2003
Posts: 2

PostPosted: Wed Oct 22, 2003 3:22 pm    Post subject: Array of Objects with 2d Arrays...uh what is happening? Reply with quote

Ok so I am pretty new to smarty. This is what I have via the debug console:

Code:
{$clients}
Array (17)
0 => client Object (10)
  client_id => 2
  client_name => Company
  client_url => url
  domain_registrar => Registrar
  domain_renewal_date => 2003-10-20
  hosting_company => Hosting
  hosting_cost => 50
  comments => This is a test!!!
  techs => Array (2)
    0 => Array (6)
      0 => 2
      client_id => 2
      1 => 3
      tech_id => 3
      2 => ASP
      tech_name => ASP
    1 => Array (6)
      0 => 2
      client_id => 2
      1 => 4
      tech_id => 4
      2 => PHP
      tech_name => PHP


As you can see I have an array of objects, which has a 2d array (techs) as one of its properties. Everything seems to be fine through the debug console. But if I do a {$clients[0]->techs[0]} I don't get "Array" as I would expect I get:

Fatal error: Smarty: [in view_clients.tpl line 1]: syntax error: unrecognized tag: $clients[0]->techs[0] (Smarty_Compiler.class.php, line 381) in Smarty/Smarty_Compiler.class.php on line 1857

If I do a {$clients} I get "Array" as expected, if I do a {$clients[0]} I get "Object" as expected, if i do {$clients[0]->techs} I get "Array" as expected. But as soon as I try to get at the stuff in that techs array everything dies.

What is going on here?

Also, maybe this is a really bad way to go about doing things, I dunno? Suggestions?
Back to top
View user's profile Send private message AIM Address
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Oct 22, 2003 4:09 pm    Post subject: Reply with quote

this is a bug in 2.4.2 (you should always mention the smarty-version you use, when you report a problem, BTW). your syntax works fine in 2.5.0
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MaxPower
Smarty n00b


Joined: 22 Oct 2003
Posts: 2

PostPosted: Wed Oct 22, 2003 4:41 pm    Post subject: Thanks! Reply with quote

Thanks messju! And next time I will be sure to post my smarty version.

Thanks again.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General 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