【发布时间】:2025-11-27 23:50:01
【问题描述】:
这是我之前的问题:How to convert a decimal $attribute['text']; into a fraction in opencart
我有一个在startup.php 中声明并在helper/dec2frac.php 中定义的辅助函数
我正在尝试使用以下代码从 category.tpl 文件调用辅助函数:
<?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() 助手/dec2frac.php
如何在category.tpl 文件中调用我的辅助函数?
我需要在我的category.php 文件中引用辅助函数吗?
【问题讨论】:
标签: php opencart opencart2.x opencart2.3