|
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 |
eadz Smarty Regular
Joined: 30 Apr 2003 Posts: 61 Location: Auckland, New Zealand
|
Posted: Tue May 27, 2003 6:32 am Post subject: modifiers getting a different varible than sections |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue May 27, 2003 7:07 am Post subject: |
|
|
I stumbled on this one too. Are you using @ before the modifer telling Smarty to expect an array?
{$var|@printr} |
|
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
|