我设法按照以下说明在我的主题中放置了一个按钮:https://doc.oroinc.com/frontend/storefront/templates/,但我想知道如何实际显示一个自定义变量的内容。
我通过mything.yml中的"vars“为mything.twig.html定义了"userName”,如https://doc.oroinc.com/frontend/storefront/templates/#custom-variables中所示,但是
{{ text|trans({'%userName%': userName})}} 显示与之前相同的文本,我尝试了
{{ dump(_context) }} 变量甚至没有出现在被转储的变量中。
发布于 2021-07-09 20:41:11
确保翻译消息不是问题。您可以在UI中执行此操作:https://doc.oroinc.com/user/back-office/system/localization/translations/#localization-translations
然后,如果您在prod环境中工作,请确保在更改后清除了缓存。在dev环境中,布局的缓存处于禁用状态。
如果上述建议不起作用,请确保将变量设置为与使用该变量的模板相同的块,因为变量的作用域是按块计算的,并且在外部不可见。
此外,您还可以使用Symfony dev工具栏查看包含所有集合变量的结果块树:https://doc.oroinc.com/frontend/storefront/debugging/#layout-tree
https://stackoverflow.com/questions/68316537
复制相似问题