How to recompile templates and phrases

Status
Not open for further replies.

Kentaurus

OMG Member
Oct 18, 2003
30
2
215
The following code snippet will "force" to recompile all templates and phrases

For phrases (change languageId to yours)
Code:
    $p = new XenForo_Model_Phrase();
    $p->compileAllPhrasesInLanguage(1);

For templates
Code:
    $t = new XenForo_Model_Template();
    $t->compileAllTemplates();

If you just need to run it for whatever reason you could add it in index.php just before fc->run()
 
  • Like
Reactions: 2,241 people

Kentaurus

OMG Member
Oct 18, 2003
30
2
215
I am currently digging into the code. Thankfully I have worked on another Zend-based project before otherwise I wouldn't understand a thing ... I'll try to share what I can. Having it highly decoupled and as easy as instantiating a class and running a method is really nice actually.
 

vlada

OMG Member
Oct 26, 2010
152
1
70
40
The following code snippet will "force" to recompile all templates and phrases

For phrases (change languageId to yours)
Code:
    $p = new XenForo_Model_Phrase();
    $p->compileAllPhrasesInLanguage(1);

For templates
Code:
    $t = new XenForo_Model_Template();
    $t->compileAllTemplates();

If you just need to run it for whatever reason you could add it in index.php just before fc->run()


Thank you very much for the useful information! It will help me a lot in my work on my project. Thanks once again for sharing!
 
Oct 6, 2010
105
9
225
32
If you ever export templates through files (not necessarily through WebDav, all though, I'm looking at a method to get webDAV to allow SVN support and write an article up on it. :D), and then just import them to the database via a query, they'd need recompiled. And... I'm pretty sure if you called a template and did any runtime editing (is that even possible?), you would need to recompile it.
 

Kentaurus

OMG Member
Oct 18, 2003
30
2
215
When would i need this?
I did some manual changes to the xf_phrase and xf_phrase_compiled tables, after that, I had to recompile all the templates to propagate the changes.

Also, if you are writing a hack, you may come across an scenario in which this is needed.
 
Status
Not open for further replies.