• 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.


Well-known member

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:

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

if ($templateId)

                        'style_id' => $styleId,
                        'title' => $templateName,
                        'template' => $templateContent,
                        'addon_id' => 'XenForo'
Then, when i click 'Save' in my form, i receive this error:

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

Change this:

'template' => $templateContent,
To this:

'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...