1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XenForo Template (XML)

Discussion in 'XenForo Development Discussions' started by Uniphix, Feb 20, 2014.

  1. Uniphix

    Uniphix Active Member

    Hey all.

    Will using XML in xenforo templates cause problems? Considering that HTML/XHTML or HTML5 is all based on the XML Environment so I'm probably answering my own question but I need confirmation.

    Basically I want to dynamically generate XML content and data right into the Template itself. So that I can use the phrases, and what not. When generated output as XML it should function just fine right?
  2. Uniphix

    Uniphix Active Member

    Nevermind on this question the answer is yes you can. I have totally utilized the entire XenForo Template system to perform special templates for a third party software and it has been working very well. =)

    SO I ended up answering my own question lol...
    TBDragon likes this.
  3. TBDragon

    TBDragon Active Member

    can u tell us how u did that ?
  4. Uniphix

    Uniphix Active Member

    I would love to show you via code but I cannot due to the company agreement I signed. But I can tell you what I did to make it work.
    1. I created a Template Compiler extending the XenForo_Template_Compiler
    2. I took the email template compiler as a good base to follow by.
    3. I removed any including method as it wasn't really needed for what I was doing
    4. I created DataWriters that we're cloned from the EmailTemplate DataWriters
    5. Using the EmailTemplate as a base example, I then basically compiled the template saved it to the database etc. I then had to extend the Phrase DataWriter to take into consideration and overriding the following functions
        * Recompiles all templates (admin and public) that include this phrase.
    protected function _recompileTemplatesIncludingPhrase()

    $templateModel $this->_getCustomTemplateModel();

    $title $this->get('title');


            if (
    $this->isChanged('title') && $this->isUpdate())
    $existingTitle $this->getExisting('title');


        * @return MyCustom_Model_CustomTemplate
    protected function _getCustomTemplateModel()
    1. In the Models, and DataWriter for CustomTemplate I removed anything relation to the 'addon' as I didn't need since it was part of the addon I already created for
    2. Then I created a simular function how XenForo_Mail::prepareContents work, and handled all the template loading, and what not. Was pretty easy once I got it working.

Share This Page