常见错误

1. 模板引用变量空值错误

关键词:The following has evaluated to null or missing

此错误表示模板中引用了值为null的数据,此类错误页面会提示错误在哪个模板的哪一行哪一列,如下所示:

{"code":500,"msg":"The following has evaluated to null or missing:\n==> Site.seoKeywords  [in template \"swikoon_pc/template/index.template.html\" at line 13, column 11]\n\n----\nTip: It's the step after the last dot that caused this error, not those before it.\n----\nTip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??\n----\n\n----\nFTL stack trace (\"~\" means nesting-related):\n\t- Failed at: ${Site.seoKeywords}  [in template \"swikoon_pc/template/index.template.html\" at line 13, column 9]\n----"}

解决方法:

  • 确认引用的变量已正确添加到模板上下文中,且变量不是null值。

  • 如果变量可为null值,找到错误的位置,通过在引用变量后添加 !'' 来设置null值默认转成空字符串,例如:${Site.seoKeywords!''}

  • 如果是 ${Content.title} 中的 Content 为null,则需要确认是否已在模板中初始化此变量。

2. 分页标识错误

关键词:Template page flag is already activated!

错误提示如下:

{"code":500,"msg":"Template page flag is already activated!\n\n----\nFTL stack trace (\"~\" means nesting-related):\n\t- Failed at: @cms_content catalogid=\"${Catalog.cat...  [in template \"swikoon_pc/template/list.template.html\" at line 75, column 11]\n----"}

在模板中使用自定义列表标签时,由于存在多个 page 属性为 true 的标签时无法正确生成分页静态页面,因此需要保证模板中只有唯一一个列表标签的 page 属性值为 true

3. 分页变量 ${OtherPage} 不存在

关键词:The following has evaluated to null or missing:\n==> OtherPage

分页变量并不是所有模板可用,目前分页变量仅在一些有分页需求的模板页面可用:

  • 栏目列表页模板(不是栏目首页模板,栏目配置时请区分清楚
  • 内容详情页模板
  • 搜索结果页模板(动态模板类型:Search)
  • 会员中心页模板(动态模板类型:AccountCentre)
{"code":500,"msg":"The following has evaluated to null or missing:\n==> OtherPage  [in template \"swikoon_pc/template/list.template.html\" at line 134, column 28]\n\n----\nTip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??\n----\n\n----\nFTL stack trace (\"~\" means nesting-related):\n\t- Failed at: ${OtherPage?replace(\"{0}\", pn)}  [in template \"swikoon_pc/template/list.template.html\" at line 134, column 26]\n----"}

4. 栏目不存在

关键词:CatalogNotFoundException: <@cms_catalog>[id: 0, alias: news1]

此错误表示模板中的 <@cms_catalog> 标签引用的栏目数据不存在,此类错误页面会提示错误在哪个模板的哪一行哪一列,如下所示错误信息表示在模板的 swikoon_pc/template/header.template.html 的第 16 行 9 列,存在 <@cms_catalog> 标签引用了不存在的栏目,栏目别名为 news1

{"code":500,"msg":"No error description was specified for this error; low-level message: com.chestnut.contentcore.template.exception.CatalogNotFoundException: <@cms_catalog>[id: 0, alias: news1]\n\n----\nFTL stack trace (\"~\" means nesting-related):\n\t- Failed at: @cms_catalog alias=\"news1\" level=\"Self\"  [in template \"swikoon_pc/template/header.template.html\" at line 16, column 9]\n\t- Reached through: @cms_include file=\"header.template.html\"  [in template \"swikoon_pc/template/index.template.html\" at line 51, column 3]\n----\n\n----\nFTL stack trace (\"~\" means nesting-related):\n\t- Failed at: @cms_catalog alias=\"news1\" level=\"Self\"  [in template \"swikoon_pc/template/header.template.html\" at line 16, column 9]\n\t- Reached through: @cms_include file=\"header.template.html\"  [in template \"swikoon_pc/template/index.template.html\" at line 51, column 3]\n----"}

解决方法:

  • 如果是栏目别名写错了,修改引用的栏目别名

  • 如果是引用的栏目不存在,后台创建相关栏目

4. 获取到的链接为什么是 iurl://

关键词:iurl

iurl是系统内部定义个一个通用链接描述符,在模板中请使用模板函数转化成正常地址

解决方法:

  • 使用模板函数 ${internalUrl(content.logo)}

5. 发布后页头页尾不显示

关键词:页头页尾不显示

页头页尾一般通过模板标签<@cms_include>引用,默认使用ssi方式,需要nginx等相关中间件配置ssi支持

解决方法:

  • nginx添加ssi配置支持

  • <@cms_include>标签设置ssi属性为false(修改后需要发布全站才能更新所有页面)