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

Automatically creating a template...

Discussion in 'XenForo Development Discussions' started by Mr. Goodie2Shoes, Jul 18, 2012.

  1. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    How does an add-on automatically creates a template upon adding a content (for example)...
    XenForo's Page Node does it, when you create a new page, XenForo automatically creates a template associating the page...
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It uses XenForo_DataWriter_Template. See this function:

  3. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    I actually looked into the classes and so far no luck... :D
    I got to look further then...
  4. ragtek

    ragtek Guest

    class Ragtek_DeveloperTools_Generator_Template{
         * @static
         * @param array $addOn
         * @param $title
         * @param $template
         * @return mixed
         * @throws XenForo_Exception
    public static function generatePublicTemplate(array $addOn$title$template){
            if (
    self::checkPublicTemplateExists($title)) {
                throw new 
    XenForo_Exception(sprintf('public template %s exists already'$title));
    $propertyModel self::_getStylePropertyModel();
    $properties $propertyModel->keyPropertiesByName(
    $propertyChanges $propertyModel->translateEditorPropertiesToArray(
    /** @var $writer XenForo_DataWriter_Template */
    $writer XenForo_DataWriter::create('XenForo_DataWriter_Template');
    'title' => $title,
    'template' => $template,
    'addon_id' => $addOn['addon_id'],
    'style_id' => 0
            try {
            } catch (
    Exception $ex) {
                throw new 
    XenForo_Exception("Exception creating template $title: " $ex->getMessage() . '<br/><pre>' htmlentities($template) . '</pre>');
    bousaid and infis like this.
  5. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Thanks ragtek! :D

Share This Page