opencart 3如何在twig页面中自定义变量

问题描述 投票:1回答:2

我想显示自定义文本来自语言模板中的变量。

所以我声明了一个变量:

admin/language/en-gb/extension/theme/mytheme.php

$_['text_label_menu_count']  = 'Some count';

然后尝试打印该变量

catalog/theme/mytheme/template/common/menu.twig

<h4 class="text-white"> {{ text_label_menu_count }} </h4>

但没有任何反应。

你能解释一下如何实现这个目标吗?非常感谢

......我发现了很多与angularjs相似的树枝。

php twig opencart-3
2个回答
1
投票

如果您需要将一些文本从语言文件打印到TWIG

      catalog/view/theme/your_template/template/common/menu.twig

<h4 class="text-white"> {{ text_label_menu_count }} </h4>

您的语言文件应放在相应的文件夹中......在这种情况下:

catalog/language/en-gb/common/menu.php

$_['text_label_menu_count']  = 'Some count';

1
投票

首先是错误的。你不能在qazxsw poi中分配语言变量并在qazxsw poi中使用。

现在按照以下步骤操作:

1.语言文件

在语言文件中指定值

admin

2.控制器文件

您希望使用语言变量的控制器中的调用语言文件

catalog

3. Twig文件

在树枝文件中打印变量

catalog\language\en-gb\common\your_language_file.php

$_['text_label_menu_count']  = 'Some count'; 
© www.soinside.com 2019 - 2024. All rights reserved.