如何在OpenCart中定义变量?

时间:2018-12-19 10:23:34

标签: opencart

<div class="form-group required">
            <label class="col-sm-2 control-label" for="input-telephone1">Confirm Telephone</label>
            <div class="col-sm-10">
              <input type="tel" name="telephone1" value="" placeholder="Confirm Telephone" id="input-telephone1" class="form-control" required/>

 <?php if ($error_telephone1) { ?>

              <div class="text-danger"><?php echo $error_telephone1; ?></div>
              <?php } ?>
            </div>
          </div>

即使我已经在语言和控制器中定义了一个变量,我仍然收到一条错误消息。错误消息如下:

错误通知:未定义的变量:第85行/home/chaarms/public_html/catalog/view/theme/default/template/account/register.tpl中的error_telephone1

1 个答案:

答案 0 :(得分:0)

在相应的控制器文件中,在您的情况下catalog / controller / account / register.php中应定义它:

$data['error_telephone1'] = "some code where  from you want to get this info";

例如,如果您要添加一些文本代码,则应该紧随其后:

$data['error_telephone1'] = $this->language->get('error_telephone1');

并在相应的语言文件中添加:

$_['error_telephone1']               = 'Telephone error!!!';

仅此而已。