从opencart 2.0.3.1中的.tpl文件引用$this时出错

从opencart 2.0.3.1中的.tpl文件引用$this时出错,opencart,loader,Opencart,Loader,我使用vqmod将此代码注入header.tpl中 <?php if ($this->customer->isLogged()){ if($this->customer->getCustomerGroupId()!=1) { ?> //show something <?php } ?> 有没有办法从2.0.3.1中的.tpl文件中引用$this?您不能从tpl调用customer类,您必须在header.php中这样

我使用vqmod将此代码注入header.tpl中

<?php if ($this->customer->isLogged()){ if($this->customer->getCustomerGroupId()!=1) { ?>
              //show something

<?php } ?>

有没有办法从2.0.3.1中的.tpl文件中引用$this?

您不能从tpl调用customer类,您必须在header.php中这样做,
将数据存储在$this->data[]中,并在tpl文件中使用它。这将是正确的程序

如果要使用OC中.tpl文件中的任何库文件,则必须先创建该类的实例,然后才能访问它,请尝试使用此实例

$customer = new Customer();
$customer->isLogged()

最新的opencartver 2.x删除了这个概念。因此,您将直接使用

$customer->isLogged

$customer = new Customer();
$customer->isLogged()