【问题标题】:Laravel displaying information in {% content %}Laravel 在 {% content %} 中显示信息
【发布时间】:2017-01-29 13:19:06
【问题描述】:

显示内容块信息有问题

{% content 'structurated/'this.page.filename %}

这会返回一个错误。如果我删除 'structurated/' {% content this.page.filename %} 它正在工作并返回内容块。但我需要从structurated/ 文件夹返回信息。如何更改可以工作的代码?

{% content 'structurated/'this.page.filename %}

ERROR:
Unexpected token "punctuation" of value "." ("operator" expected with value "=").
==========
{% content 'structurated/'.this.page.filename %}

An exception has been thrown during the rendering of a template ("The content file '' is not found.").
==========
{% content 'structurated/'+this.page.filename %}

An exception has been thrown during the rendering of a template ("The content file '0' is not found.").

【问题讨论】:

  • 请发布错误。乍一看,它不像您正确连接字符串和变量那样接缝。我不确定语法,但可能是'structurated/'.this.page.filename'structurated/'+this.page.filename
  • 我更新问题时出现错误。
  • 如果你明确输入文件名会发生什么?喜欢{% content 'structurated/my_file' %}
  • 如果我输入 {% content 'structurated/advertising.htm' %} 就可以了。
  • 好的,所以肯定是串联。您使用的模板语法是什么?

标签: php laravel twig octobercms


【解决方案1】:

应该这样做。

{% content 'structurated/' ~ this.page.filename %}

现在连接不正确

【讨论】:

  • 很高兴听到! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-02-26
  • 1970-01-01
  • 2016-08-18
  • 1970-01-01
  • 2021-08-03
  • 1970-01-01
  • 2020-03-29
相关资源
最近更新 更多