|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
MaxPower Smarty n00b
Joined: 22 Oct 2003 Posts: 2
|
Posted: Wed Oct 22, 2003 3:22 pm Post subject: Array of Objects with 2d Arrays...uh what is happening? |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Oct 22, 2003 4:09 pm Post subject: |
|
|
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 |
|
MaxPower Smarty n00b
Joined: 22 Oct 2003 Posts: 2
|
Posted: Wed Oct 22, 2003 4:41 pm Post subject: Thanks! |
|
|
Thanks messju! And next time I will be sure to post my smarty version.
Thanks again. |
|
Back to top |
|
|
|
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
|