Php 如何调用category.tpl文件OpenCart 2中的helper函数

Php 如何调用category.tpl文件OpenCart 2中的helper函数,php,opencart,opencart2.x,opencart2.3,Php,Opencart,Opencart2.x,Opencart2.3,这是我先前的问题: 我有一个helper函数,它在startup.php中声明,在helper/dec2frac.php 我试图使用以下代码从category.tpl文件调用helper函数: <?php if ($product['attribute_groups']) { ?> <?php foreach ($product['attribute_groups'] as $attribute_group) { ?>

这是我先前的问题:

我有一个helper函数,它在
startup.php
中声明,在
helper/dec2frac.php

我试图使用以下代码从
category.tpl
文件调用helper函数:

  <?php if ($product['attribute_groups']) { ?>
                   <?php foreach ($product['attribute_groups'] as $attribute_group) { ?>
                       <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
                        <?php /*var_dump($attribute);*/

                       if($attribute['name'] == "Adjuster Position")
                       {
                          //echo("<h1>HELLLO</h1>");
                          dec2frac($attribute['text']);
                       }


                        ?>

…但我收到了以下错误消息:

致命错误:在startup.php中调用未定义的函数dec2frac() helper/dec2frac.php

如何在
category.tpl
文件中调用我的helper函数?
我是否需要引用我的
category.php
文件中的helper函数?

我正在尝试以不同的方式实现相同的功能。以下链接将有所帮助,它将与opencart v2.3x一起使用

尝试上面的链接(这是我发布的问题)。创建一个对象并将其保存在注册表中,然后从注册表中获取该对象并调用所需的函数

在category.php文件中,从注册表获取对象。例如:

$kt = $registry->get('ktLibrary'); //Object
$value = $kt->getSomeValue(); //function
对象$kt将在category.tpl文件中提供