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

Problem when creating template throug script.

Fuhrmann

Well-known member
#1
Hey!

I made a form with a textbox and some other fields. It's basically the same form that when we want to add a new template. But it's my form with some other things.

I am trying to create a template by this script, but i always get a error. See, this is the partial code for save:

PHP:
$writer = XenForo_DataWriter::create('XenForo_DataWriter_Template');
$templateId = $this->_getTemplateModel()->getTemplateIdInStylesByTitle($templateName);

if ($templateId)
{
    $writer->setExistingData($templateId[0],true);
}

$writer->bulkSet(array(
                        'style_id' => $styleId,
                        'title' => $templateName,
                        'template' => $templateContent,
                        'addon_id' => 'XenForo'
                    ));
Then, when i click 'Save' in my form, i receive this error:

Code:
Line 1: Template syntax error.
Then, i tried this way:

Change this:

PHP:
'template' => $templateContent,
To this:

PHP:
'template' => '<li></li>',
And works! The template is saved normal. Is there a problem that i am passing the value of 'template' into a variable? I can see in another way...