Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Multiple/Styles : Suggestions of Best Practice?
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
TakingSides
Smarty Rookie


Joined: 11 Dec 2010
Posts: 30

PostPosted: Tue Aug 16, 2011 8:50 am    Post subject: Reply with quote

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
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Tue Aug 16, 2011 9:02 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
TakingSides
Smarty Rookie


Joined: 11 Dec 2010
Posts: 30

PostPosted: Tue Aug 16, 2011 9:57 am    Post subject: Reply with quote

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
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Tue Aug 16, 2011 10:05 am    Post subject: Reply with quote

Smarty2 knew the method clear_compiled_tpl() which did the same thing…
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
edward
Smarty Rookie


Joined: 15 Aug 2016
Posts: 5

PostPosted: Mon Aug 15, 2016 11:13 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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
Protected by Anti-Spam ACP