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

modifiers getting a different varible than sections

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
eadz
Smarty Regular


Joined: 30 Apr 2003
Posts: 61
Location: Auckland, New Zealand

PostPosted: Tue May 27, 2003 6:32 am    Post subject: modifiers getting a different varible than sections Reply with quote

Am I missing something?

The following doesn't work when passed array like :

{$post.sections|printr}

[php:1:3d264fe853]<?php
function smarty_modifier_printr(&$var)
{
ob_start();
print_r($var);
$o = ob_get_contents();
ob_end_clean();
return "<pre>".$o."</pre>";
}
?>[/php:1:3d264fe853]

it just returnes "Array"

But
{section name=n loop=$post.sections} some stuff {/section} loops over the array.

If I make a custom looping block function, and pass it a varible, would I expect the same behavior ? ( i.e. can't get the array )

edit: this DOES work :

{printr var=$post.sections}

[php:1:3d264fe853]<?php
function smarty_function_printr($params, &$Smarty)
{
ob_start();
print_r($params['var']);
$o = ob_get_contents();
ob_end_clean();
return "<pre>".$o."</pre>";
}
?>[/php:1:3d264fe853]

so what happens to the modifier? is it converted into a string first?
_________________
bBlog - Smarty based blogging software
I work for Webforce web site design ( Auckland, NZ )
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue May 27, 2003 7:07 am    Post subject: Reply with quote

I stumbled on this one too. Are you using @ before the modifer telling Smarty to expect an array?

{$var|@printr}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins 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