自定义多语言输入 - opencart

时间:2017-08-29 15:19:21

标签: input field opencart multilingual

在管理员方面,在opencart中创建多语言输入的模式是什么 例如,我希望有两个List Description Limit输入,每种语言一个 就像在这image中一样。因此,我可以从管理员控制每种语言的列表限制 目前我使用此模式创建自定义输入,但这不依赖于语言:

File: admin/view/template/extension/theme/theme_default.tpl
<fieldset>
<div class="form-group required">
  <label class="col-sm-2 control-label" for="inputId"><span data-toggle="tooltip" title="<?php echo $help_inputName; ?>"><?php echo $label_inputName; ?></span></label>
  <div class="col-sm-10">
    <input type="text" name="theme_default_inputName" value="<?php echo $theme_default_inputName; ?>" placeholder="<?php echo $label_inputName; ?>" id="inputId" class="form-control" />
    <?php if ($error_inputName) { ?>
    <div class="text-danger"><?php echo $error_inputName; ?></div>
    <?php } ?>
  </div>
</div>
</fieldset>

File: admin/language/en-gb/extension/theme/theme_default.php
//Language strings
$_['help_inputName']                   = 'helpTxt';
$_['label_inputName']                  = 'labelForInput';
$_['error_inputName']                  = 'errorForInput';

File: admin/controller/extension/theme/theme_default.php
//Language strings
$text_strings = array(
    'help_inputName',
    'label_inputName',
    'error_inputName'
);

foreach ($text_strings as $text) {
    $data[$text] = $this->language->get($text);
}

//Error handling
if (isset($this->error['inputName'])) {
    $data['error_inputName'] = $this->error['inputName'];
} else {
    $data['error_inputName'] = '';
}

//Custom field
if (isset($this->request->post['theme_default_inputName'])) {
    $data['theme_default_inputName'] = $this->request->post['theme_default_inputName'];
} elseif (isset($setting_info['theme_default_inputName'])) {
    $data['theme_default_inputName'] = $setting_info['theme_default_inputName'];
} else {
    $data['theme_default_inputName'] = "customText";
}

//Validation
if (!$this->request->post['theme_default_inputName']) {
    $this->error['inputName'] = $this->language->get('error_inputName');
}

0 个答案:

没有答案