0

我正在将 VirtueMart 2.0.10 与 Joomla 一起使用!2.5.6,我的问题是每个产品的自动生成的 pdf 文档不包括我的自定义字段。我不是 php 专家,但我认为文件/components/com_virtuemart/views/productdetails/tmpl/default_pdf.php中的这些行与它有关,从第 145 行开始:

    <?php // Product custom_fields TODO relation to Childs
if (!empty($this->product->customfields)) { ?>
    <div class="product-fields">
    <?php
    $custom_title = null ;
    foreach ($this->product->customfields as $field){
        ?><div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field_type ?>">
        <?php if ($field->custom_title != $custom_title) { ?>
            <span class="product-fields-title" ><strong><?php echo JText::_($field->custom_title); ?></strong></span>
            <?php //echo JHTML::tooltip($field->custom_tip, $field->custom_title, 'tooltip.png');
        } ?>
        <span class="product-field-display"><?php echo $field->display ?></span>
        <span class="product-field-desc"><?php echo jText::_($field->custom_field_desc) ?></span>
        </div>
        <?php
        $custom_title = $field->custom_title;
    } ?>
    </div>
    <?php
} // Product custom_fields END ?>

我测试了在上面的 if 语句之后添加一个 else 语句来回显一些文本,它执行了。所以显然没有自定义字段......但确实有......

我还没有发现其他人遇到这个问题,我认为这很奇怪,但我不认为我搞砸了。我在/components/com_virtuemart/views/productdetails/tmpl/default.php文件中做了一些更改。

4

1 回答 1

0

我删除了我在问题中输入的所有代码,并将其替换为/components/com_virtuemart/views/productdetails/tmpl/default.php文件中的以下代码:

<?php
$custom_title = null;
foreach ($this->product->customfieldsSorted['normal'] as $field) { // I set the position to normal
if ( $field->is_hidden )
continue;
if ($field->display) {
?>
<?php if ($field->custom_title != $custom_title) { ?>
<b><?php echo JText::_($field->custom_title); ?></b><br />

<?php
if ($field->custom_tip)
echo JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png');
}
?>
<?php echo $field->display ?><br />
<?php echo jText::_($field->custom_field_desc) ?><br />
<?php
$custom_title = $field->custom_title;
}
}
?>

我不是专家,但这对我有用。PDF 现在包括自定义字段。

正如您在代码中的注释中看到的,我将位置更改为'normal'。其他位置似乎是'ontop''onbot'。但我不会更改该设置,所以我保留它。

编辑:我忘了提到我在该段中添加了一些其他的 html 代码,就像<br />并且<b>只是为了出现。所以没什么大不了的,只是为了澄清代码与文件default.php中的代码不完全一样

于 2012-10-17T12:06:47.300 回答