|
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 |
TakingSides Smarty Rookie
Joined: 11 Dec 2010 Posts: 30
|
Posted: Tue Aug 16, 2011 8:50 am Post subject: |
|
|
Quote: | no, second parameter of display is the cache_id, third is the compile_id: Code: | $smarty->display('index.tpl', null, 'en_GB'); |
|
That makes sense, However one thing has just crossed my mind...
Once you have compiled your templates, what if you change a piece of text? Only on one language, on a few pages?
The reason I manually separated languages, is when you change any language I use glob() to delete all compiled templates with instances of the changed text (by tag). Smarty then recompiles. I could technically touch() the .tpl file with such instances, for Smarty to recompile?
For example....
Template:
Code: | <div>
<h1 title="# TTL_WELCOME_TITLE #"># TTL_WELCOME #</h1>
<p># TXT_WELCOME # </p>
</div> |
Compiled:
./Smarty/generated/default/en_GB/index.tpl.php
./Smarty/generated/default/de_DE/index.tpl.php
I change:
TTL_WELCOME_TITLE for English! It's impractical to delete ALL compiled templates, It's also impracticable to recompile templates every single time!
So I find all files with TTL_WELCOME_TITLE in the generated/*/en_GB/*
and delete them. |
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
Posted: Tue Aug 16, 2011 9:02 am Post subject: |
|
|
TakingSides wrote: | Once you have compiled your templates, what if you change a piece of text? Only on one language, on a few pages? |
Smarty3 offers the clearCompiledTemplate() method, allowing you to delete specific compilations. A simple Code: | $smarty->clearCompiledTemplate("foobar.tpl", "en_GB"); | would kill the english file of foobar.tpl.
You can still grep through your templates to identify those using the changed marker. Then run those filenames through clearCompiledTemplate(). _________________ Twitter |
|
Back to top |
|
TakingSides Smarty Rookie
Joined: 11 Dec 2010 Posts: 30
|
Posted: Tue Aug 16, 2011 9:57 am Post subject: |
|
|
Awesome, was this a new feature in Smarty3? I upgraded my site from smarty2 to smarty3, i think that's why some of the work-arounds are "old" or "long-winded"
I shall be using this method in future however. Which means creating a widget based MVC application with Smarty has just got even more simpler. |
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
Posted: Tue Aug 16, 2011 10:05 am Post subject: |
|
|
Smarty2 knew the method clear_compiled_tpl() which did the same thing… _________________ Twitter |
|
Back to top |
|
edward Smarty Rookie
Joined: 15 Aug 2016 Posts: 5
|
Posted: Mon Aug 15, 2016 11:13 am Post subject: |
|
|
That's just the type of reply I was looking for!
The setup you have there seems to make a lot of sense and even answers me a few questions I was starting to form about how to deal with sharing of templates. |
|
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
|