View previous topic :: View next topic |
Author |
Message |
moiseyo Smarty n00b
Joined: 03 Sep 2009 Posts: 1
|
Posted: Thu Sep 03, 2009 5:33 pm Post subject: How to force compiling after template change |
|
|
m looking into Smarty , and ran into problem that after template , compiles in need to delete it in cach before I can see changes in i made in template .
Do you know how to force compile every time i made cages in template.
I looked into doc , bot did not see , looks like a smile question.
am using:
$smarty->display('property/p_list.tpl',false);
is there better way ?
Moisey O | Do not keep all eggs in the same basket
| Microsalt
Go to Previous message | |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Sep 03, 2009 6:56 pm Post subject: |
|
|
Smarty should recompile templates if they are changed. Be sure that:
Code: | $smarty->compile_check = true; |
which is the default setting.
Also be sure that caching is disabled if you don't want to see the cache every time. If you want cache and compile recreated every time, set:
Code: | $smarty->force_compile = true; |
Be sure to disable that before going to production. |
|
Back to top |
|
conlonm Smarty n00b
Joined: 22 Oct 2009 Posts: 1
|
Posted: Thu Oct 22, 2009 7:55 pm Post subject: |
|
|
I have had a similar problem with updated templates not being displayed. For instance, if I update the footer.tpl file on my site - changing the date to 2009 - the footer isn't displayed once uploaded. I can only resolve the problem by uploading the old file with the old date stamp.
Code: | $smarty->compile_check = true; |
is set to 'true' already. I tried
Code: | $smarty->force_compile = true; |
but that made no difference. The updated template wasn't displayed. The site is working but I can't update certain sections of it which is a bit limiting. Can you suggest anything else I could try? |
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Sat Oct 24, 2009 1:14 pm Post subject: Compile everytime :-) |
|
|
Unless you are in a production stage, you should consider compiling templates everytime, to avoid these problems.
If you execute the below codes, it guarantees that all complied files are removed, and Smarty will force itself to recomplie (because there will be nothing to cache).
Code: | # Cleanup Smarty's compiled pages.
$smarty->clear_compiled_tpl(); |
When you complete your project and move to the production, you can remove this line of code, and enable caching. |
|
Back to top |
|
webcoder26 Smarty n00b
Joined: 11 Jul 2013 Posts: 1
|
Posted: Thu Jul 11, 2013 7:11 am Post subject: Re: Compile everytime :-) |
|
|
bimal wrote: | Unless you are in a production stage, you should consider compiling templates everytime, to avoid these problems.
If you execute the below codes, it guarantees that all complied files are removed, and Smarty will force itself to recomplie (because there will be nothing to cache).
Code: | # Cleanup Smarty's compiled pages.
$smarty->clear_compiled_tpl(); |
When you complete your project and move to the production, you can remove this line of code, and enable caching. |
Where should I add this code please? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Jul 11, 2013 7:16 pm Post subject: |
|
|
Normally
Code: | $smarty->compile_check = true; |
which is also the default setting should do the job that updated template get automatically recompiled.
This may fail when you are uploading template files to a server and the system clocks are out of sync.
As mentioned before for such cases
Code: | $smarty->force_compile = true; |
could be usefull during development.
Calling
Code: | $smarty->clearCompiledTemplate(); |
does not make too much sense |
|
Back to top |
|
henryejemuta Smarty n00b
Joined: 04 Sep 2018 Posts: 1
|
Posted: Tue Sep 04, 2018 9:45 am Post subject: Re: Compile everytime :-) |
|
|
webcoder26 wrote: | bimal wrote: | Unless you are in a production stage, you should consider compiling templates everytime, to avoid these problems.
If you execute the below codes, it guarantees that all complied files are removed, and Smarty will force itself to recomplie (because there will be nothing to cache).
Code: | # Cleanup Smarty's compiled pages.
$smarty->clear_compiled_tpl(); |
When you complete your project and move to the production, you can remove this line of code, and enable caching. |
Where should I add this code please?
|
I had same issue but all works fine after I specify the $cache_id which I think must be unique to any of your dynamic generated content...
Below is an example of how I display or fetch any dynamic content:
Code: |
if(!$app->isCached('dynamic_page.tpl', $page_unique_id)) {
// No cache available, do variable assignments here.
$dynamicObject = new SomeObject();
$app->assign('dynamicObject', $dynamicObject);
}
$app->display('dynamic_page.tpl', $page_unique_id);
|
...more details about this can be found on the link below:
https://www.smarty.net/docs/en/caching.multiple.caches |
|
Back to top |
|
|