gpt4 book ai didi

php - 商店设置中的 Opencart 3 多语言字段

转载 作者:行者123 更新时间:2023-12-04 09:29:40 27 4
gpt4 key购买 nike

我想在 Opencart 3 商店设置中设置多语言“开放”字段。
在 admin\view\template\setting\setting.twig 中。
我找到了这些行:

<div class="form-group">
<label class="col-sm-2 control-label" for="input-open"><span data-toggle="tooltip" data-container="#tab-general" title="{{ help_open }}"> {{ entry_open }}</span></label>
<div class="col-sm-10">
<textarea name="config_open" rows="5" placeholder="{{ entry_open }}" id="input-open" class="form-control">{{ config_open }}</textarea>
</div>
</div>
我是从 textarea 制作的 - 输入并添加 {% for language in languages %} 、语言标志和语言 ID。
{% for language in languages %}
<div class="form-group">
<label class="col-sm-2 control-label" for="input-open{{ language.language_id }}"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /><span data-toggle="tooltip" data-container="#tab-general" title="{{ help_open }}"> {{ entry_open }}</span></label>
<div class="col-sm-10">
<input type="text" name="config_open[{{ language.language_id }}][title]" placeholder="{{ entry_open }}" id="input-open{{ language.language_id }}" value="{{ config_open[language.language_id] ? config_open[language.language_id].title }}" class="form-control" />
</div>
</div>
{% endfor %}
此后,在商店设置中,我有两种语言的“打开”字段。现在存储这些字段中的信息。
在前端 Controller 中,我做了这个。
$data['open'] = nl2br($this->config->get('config_open'));
什么时候一种语言都可以工作,但现在我有一个错误:
Warning: nl2br() expects parameter 1 to be string, array given in /var/www/fastuser/data/www/localstite.loc/storage/modification/catalog/controller/common/header.php on line 81

最佳答案

已编辑...
对应的 Controller 文件必须包含以下代码:

$this->load->model('localisation/language');
$languages = $this->model_localisation_language->getLanguages();

foreach ($languages as $language) {
if (isset($this->request->post[config_open' . $language['language_id']])) {
$data['config_open'][$language['language_id']] = $this->request->post['config_open' . $language['language_id']];
} else {
$data['config_open'][$language['language_id']] = $this->config->get('config_open' . $language['language_id']);
}
}
线:
 <input type="text" name="config_open[{{ language.language_id }}][title]" placeholder="{{ entry_open }}" id="input-open{{ language.language_id }}" value="{{ config_open[language.language_id] ? config_open[language.language_id].title }}" class="form-control" />
用。。。来代替:
 <input type="text" name="config_open{{ language.language_id }}" placeholder="{{ entry_open }}" id="input-open{{ language.language_id }}" value="{% if config_open[language.language_id] %}{{ config_open[language.language_id] }}{% endif %}" class="form-control" />
和前端线:
$data['open'] = nl2br($this->config->get('config_open'));
用。。。来代替:
$data['open'] = nl2br($this->config->get('config_open' . $this->config->get('config_language_id')));

关于php - 商店设置中的 Opencart 3 多语言字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62894579/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com