|
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 |
adn Smarty Regular
Joined: 31 May 2011 Posts: 91
|
Posted: Mon Jun 23, 2014 6:24 pm Post subject: |
|
|
Hello,
I have the last smarty code and I used the followinf config
Code: | $smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);
$smarty->setCompileCheck(FALSE);
$smarty->setDebugging(FALSE);
$smarty->setMergeCompiledIncludes(TRUE);
$smarty->setUseSubDirs(TRUE);
$smarty->setCacheLifetime(-1);
$smarty->inheritance_merge_compiled_includes = false; |
For some includes I use the inline option. For me that means that the output of this include should not change as the page doesn't change but I see that the result is not the same with the first display and the second one !
It seems that the include is not really inline.
What's wrong? _________________ http://www.letsGarden.info |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Jul 14, 2014 8:40 pm Post subject: |
|
|
"include inline" merely states, that the template included will not be using it's own caching as long as the page including it is not regenerated.
As an example, imagine this template code:
template 1: Code: | {*
Smarty template
$Id: svgimage.tpl 204 2013-08-07 19:41:51Z anrdaemon $
*}
<object type="image/svg+xml" data="{$imageName|escape}"{if
$id} id="{$id|escape}"{/if}{if
$class} class="{$class|escape}"{/if}{if
$style} style="{$style|escape}"{/if}>{*
*}<param name="src" value="{$imageName|escape}"/>{if
$fallback}{include $fallbackTemplate inline}{/if}</object> |
template 2: Code: | {*
Smarty template
$Id: svgfallback.tpl 204 2013-08-07 19:41:51Z anrdaemon $
*}
{if $fallbackLink}<a href="{$fallbackLink|escape}">{/if}{if $fallbackImage}<img src="{$fallbackImage|escape}"{if
$class} class="{$class|escape}"{/if}{if
$fallbackText} alt="{$fallbackText|escape}"{/if}/>{/if}{if $fallbackText and $fallback & 1}{$fallbackText|escape}{/if}{if $fallbackLink}</a>{/if} |
Both templates are cached forever, but cached version of second teplate is never read, because cached version of first template include it literal.
However, if caching is disabled or disrupted (i.e. cache directory can not be written), both templates will be regenerated each time they are called. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Jul 15, 2014 1:59 am Post subject: |
|
|
We must sort 2 things out. There are compiled files and cache file (when caching is enabled)
When caching is disabled the output gets rendered on each call from the compiled files. Normally each template file has it's own compiled file. If you have for example 1 main template and 2 subtemplates Smarty has to read 3 compiled template files.
Now if you enable the MergeCompiledIncludes option or use {include inline} the compiled code of the subtemplates gets merged into the compiled main template file. When the page is called now Smarty has to read just one compiled file.
There are 2 things to note:
1. Smarty will not merge subtemplates which have a variable file name. It can't be done because each call my request a different subtemplate. So in the example of AnrDarmon the sub template {include $fallbackTemplate inline} never gets merged.
2. If you change the MergeCompiledIncludes status it does not affect existing compiled files. You should delete the existing compiled files to force a recompile.
All of the above has nothing to do with caching. If caching is enabled the rendered output of the compiled files gets saved in a cache file which gets used once rendered. If you use caching there in no benefit of merging the subtemplate unless for the rare case when the cache file will be regenerated.
If you say the cached page does look different on the first and second call what kind of differences? |
|
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
|