XenForo Template (XML)

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?
 
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...
 
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...
can u tell us how u did that ?
 
can u tell us how u did that ?

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
PHP:
/**
    * Recompiles all templates (admin and public) that include this phrase.
    */
    protected function _recompileTemplatesIncludingPhrase()
    {
        parent::_recompileTemplatesIncludingPhrase();

        $templateModel = $this->_getCustomTemplateModel();

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

        $templateModel->compileCustomTemplatesThatIncludePhrase($title);

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

            $templateModel->compileCustomTemplatesThatIncludePhrase($existingTitle);
        }
    }

    /**
    * @return MyCustom_Model_CustomTemplate
    */
    protected function _getCustomTemplateModel()
    {
        return $this->getModelFromCache('MyCustom_Model_CustomTemplate');
    }

  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.
 
Back
Top Bottom