【问题标题】:virtuemart 2 product pdf does not display custom fields美德 2 产品 pdf 不显示自定义字段
【发布时间】:2012-10-09 07:22:29
【问题描述】:

我正在将 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 文件中做了一些更改。

【问题讨论】:

    标签: pdf joomla2.5 product virtuemart custom-fields


    【解决方案1】:

    我删除了我在问题中输入的所有代码,并将其替换为文件 /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 代码,例如 &lt;br /&gt;&lt;b&gt; 只是为了出现。所以没什么大不了的,只是为了澄清代码与文件中的代码不完全一样 default.php

    【讨论】:

      猜你喜欢
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 2020-12-04
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多