How to recompile templates and phrases

Status
Not open for further replies.

Kentaurus

OMG Member
Joined
Oct 18, 2003
Messages
30
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()
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,101
Very nice! Nice find and kind of you to share. This fixed one of my scripts, that's for sure :D
 

Kentaurus

OMG Member
Joined
Oct 18, 2003
Messages
30
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
Joined
Oct 26, 2010
Messages
152
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!
 
Joined
Oct 6, 2010
Messages
105
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
Joined
Oct 18, 2003
Messages
30
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.
Top