我的网站无法正常工作。我收到以下错误:
第8行模板“ tpl_head:tpl_head:16”中的语法错误“!function(f,b,e,v,n,t,s){if(f.fbq)return; n = f.fbq = function (){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};“;” -意外的“。”,应为以下之一:“”,“”,“)”
我一直在寻找解决问题的方法。但是我一直死胡同。
堆栈跟踪如下:
0 /lib/smarty/sysplugins/smarty_internal_templateparser.php(2727):Smarty_Internal_TemplateCompilerBase-> trigger_template_error()
1 /lib/smarty/sysplugins/smarty_internal_templateparser.php(2786):Smarty_Internal_Templateparser-> yy_syntax_error(45,'。']
2 /lib/smarty/sysplugins/smarty_internal_smartytemplatecompiler.php(114):Smarty_Internal_Templateparser-> doParse(45,'。']
3 /lib/smarty/sysplugins/smarty_internal_templatecompilerbase.php(404):Smarty_Internal_SmartyTemplateCompiler-> doCompile('\ r \ n ...',true)
4 /lib/smarty/sysplugins/smarty_internal_templatecompilerbase.php(336):Smarty_Internal_TemplateCompilerBase-> compileTemplateSource(Object(Smarty_Internal_Template),false,NULL)
5 /lib/smarty/sysplugins/smarty_template_compiled.php(204):Smarty_Internal_TemplateCompilerBase-> compileTemplate(Object(Smarty_Internal_Template))
6 /lib/smarty/sysplugins/smarty_template_compiled.php(100):Smarty_Template_Compiled-> compileTemplateSource(Object(Smarty_Internal_Template))
7 /lib/smarty/sysplugins/smarty_template_compiled.php(163):Smarty_Template_Compiled-> process(Object(Smarty_Internal_Template))
8 /lib/smarty/sysplugins/smarty_internal_template.php(206):Smarty_Template_Compiled-> render(Object(Smarty_Internal_Template))
9 /lib/smarty/sysplugins/smarty_internal_templatebase.php(216):Smarty_Internal_Template-> render(false,0)
10 /lib/smarty/sysplugins/smarty_internal_templatebase.php(107):Smarty_Internal_TemplateBase-> _ execute(Object(Smarty_Internal_Template),NULL,NULL,NULL,0)
11 index.php(161):Smarty_Internal_TemplateBase-> fetch()
12 {main}
[如果有人可以帮助我让我理解可能是什么问题,我将非常感激。请帮助。
问题是Smarty(使用的PHP模板引擎)试图立即解析任何大括号{}中的所有内容,即您的JavaScript。
因此您可以:
将{literal} {/ literal}标签放在您的javascript外部
在您的JavaScript中,在每个左花括号后加一个空格'{',并在每个右花括号前加一个空格'}'。这告诉Smarty这不是Smarty代码,并且不对其进行解析。
将您的JavaScript放在单独的文件中