![Smarty Forum Index Smarty Forum Index](templates/smarty/images/phpbb2_logo.gif) |
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 |
ilyalyu Smarty Regular
Joined: 03 Nov 2009 Posts: 72
|
Posted: Tue Oct 23, 2012 2:51 pm Post subject: Prefilters |
|
|
In some cases I get different result when:
1. My template contains code X and I have prefilter that converts code X to code Y
and when:
2. My template contains code Y and no prefilter
Why don't you apply prefilter right after you get content with getContent function? I think that in this case if you get code Y after prefilter you will get exactly the same result as if you had code Y initially and did not apply any prefilters.
To be more specific, I am trying to redefine function delcared in base template. For this I use blocks:
base template: {block a}{function a}code version 1{/function}{/block}
child template: {block a}{function a}code version 2{/function}{/block}
This works as I expect (function is redefined and outputs "code version 2" instead of "code version 1"). However, adding {block} to every function manually is inconvenient, so I have written prefilter that does this work (i.e. it adds block to every function definition). So now I have:
base template: {function a}code version 1{/function}
child template: {function a}code version 2{/function}
and prefilter adds blocks, so that the code after prefilters is the same as above. However, this does not work. So I get different result, though the code after applying prefilters is the same in both cases. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Oct 23, 2012 6:31 pm Post subject: |
|
|
I'm currently out of office for a week and will look into it when I'm back.
But you may be right that {block} tags of inheritance are processed before the prefilter so you can't currently add {block} tags by the filter. |
|
Back to top |
|
ilyalyu Smarty Regular
Joined: 03 Nov 2009 Posts: 72
|
Posted: Thu Nov 15, 2012 8:33 pm Post subject: |
|
|
Any news here? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Nov 17, 2012 12:34 pm Post subject: |
|
|
This problem will not occur in the upcomming major release of 3.2 as the internals of template inheritance have been completely rewritten.
I will try to implement a fix for 3.1 but that is not as easy as running the prefilters at the time of getContent. Because of the internals this would cause that the prefilters to run twice in other cases.... |
|
Back to top |
|
ilyalyu Smarty Regular
Joined: 03 Nov 2009 Posts: 72
|
Posted: Sat Nov 17, 2012 3:52 pm Post subject: |
|
|
I have already found temporary fix. So, I can wait for the 3.2 version. |
|
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
|