|
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 |
SlowFox Smarty Regular
Joined: 02 Oct 2006 Posts: 55
|
Posted: Thu Mar 03, 2011 1:00 pm Post subject: Output in the first iteration of a repeated block function |
|
|
I have a custom repeated block function which demands some output (preamble) even if it is called 0 times. No problem I thought: just change return the content (instead of NULL) and set $repeat to false.
While repeat does work fine, no content is generated. Looking in the source shows the reason: while the block function is called with "echo {$function}" for the subsequent calls, the first one is not.
Why?
For normal usage the function does not return anything anyway - but if it does so for whatever reason, I think it should be passed on. I added the "missing" echo-statements in all appropriate locations (hopefully) and could until now not see any harm caused by this.
Would it be possible to change this behaviour? (The current/expected behaviour is not documented in http://www.smarty.net/docsv2/en/plugins.block.functions.tpl anyways; passing through any content would be more natural in my eyes). |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Mar 03, 2011 7:34 pm Post subject: |
|
|
Your intended usage of a block plugin is a special case. If you want create output on the opening tag you must include the echo statement in your plugin. A general change of this behaviour could have sideefects on existing plugins and the standard handling of modifiers attached to the tag. |
|
Back to top |
|
SlowFox Smarty Regular
Joined: 02 Oct 2006 Posts: 55
|
Posted: Thu Mar 10, 2011 12:55 pm Post subject: |
|
|
U.Tews wrote: | Your intended usage of a block plugin is a special case. If you want create output on the opening tag you must include the echo statement in your plugin. A general change of this behaviour could have sideefects on existing plugins and the standard handling of modifiers attached to the tag. |
In understand the problem with side effects. An echo statement in a plugin breaks quite a couple of design paradigms on the other hand.
Isn't there any more canonical way to achieve this? |
|
Back to top |
|
SlowFox Smarty Regular
Joined: 02 Oct 2006 Posts: 55
|
Posted: Tue Oct 11, 2011 1:20 pm Post subject: |
|
|
SlowFox wrote: | Isn't there any more canonical way to achieve this? |
I just realized that this has been changed in 3.1 and thus switched to the latest release.
Great work, I am impressed by the new internal interfaces. Things start looking really smart now ;-) |
|
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
|