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

Smarty 3 beta 5 released
Goto page Previous  1, 2, 3
 
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 -> Smarty 3
View previous topic :: View next topic  
Author Message
toycat
Smarty Rookie


Joined: 29 Dec 2009
Posts: 8

PostPosted: Thu Jan 07, 2010 9:16 pm    Post subject: missed that Reply with quote

U.Tews wrote:
I don't see where the problem is. In Smarty3 you can use something like

$var['var2']->var3['var4']->var5...

or

$var.var2->var3.var4->var5...

So there should be no need for any typecasting.

{foreach} does already iterate over the properties of an object.


My apologies, I somehow missed this. Tried it and works superb. Thank you.
Back to top
View user's profile Send private message
httpete
Smarty Rookie


Joined: 05 Dec 2009
Posts: 27

PostPosted: Thu Jan 07, 2010 10:27 pm    Post subject: New Error after latest update Reply with quote

My previous error was fixed, but this started breaking after the latest update from SVN.

{if $smarty.request.showonlynew|strtolower eq 'on'}

needed to become:

{if strtolower($smarty.request.showonlynew) eq 'on'}

Is this expected?
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri Jan 08, 2010 3:41 pm    Post subject: Reply with quote

Some necessary parser changes did introduce a problem when using modifiers in if conditions or arithmetic expressions. A workround until this is fixed is to use parenthesis like

{if ($smarty.request.showonlynew|strtolower) eq 'on'}
Back to top
View user's profile Send private message
httpete
Smarty Rookie


Joined: 05 Dec 2009
Posts: 27

PostPosted: Fri Jan 08, 2010 7:23 pm    Post subject: Reply with quote

Cool - I can wait as long as this is fixable, I am retrofitting a huge existing smarty 2 site, so I cannot change all the places. Please let me know when this is addressed.
Back to top
View user's profile Send private message
httpete
Smarty Rookie


Joined: 05 Dec 2009
Posts: 27

PostPosted: Mon Jan 11, 2010 3:11 pm    Post subject: New Bug? Nested object property accessors in smarty Reply with quote

I found an interesting thing that broke when I upgraded to smarty 3. Accessing nested object properties doesn't work. Example:

$o = new stdClass;
$p = new stdClass;
$q = new stdClass;

$q->prop = 3;
$p->prop = $q
$o->prop = $p;

$smarty->assign('o' , $o);

if in smarty you go

{$o->prop->prop} you get "property undefined". One level depth seems to work fine.

I did the same thing with arrays and it worked fine.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Jan 11, 2010 5:01 pm    Post subject: Reply with quote

It does work fine at my place. Maybe you have had some misspelling.

But to get an output of 3 you need

{$o->prop->prop->prop}
Back to top
View user's profile Send private message
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 -> Smarty 3 All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
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