1

我正在尝试通过管理产品页面的描述部分中的输入字段在我的产品中添加一个 pdf 文件。现在我已经在视图部分创建了字段(product_file),它发送了附加的 pdf。我的问题是我不知道表单发送参数的确切位置,我无法分配我的 product_file 字段以将名称作为字符串保存在数据库中,同时将文件另存为 pdf 在文件夹中主目录。我使用 Joomla 3.4.1 和 Virtuemart 3.0.6.4。任何意见是极大的赞赏。

ps 我知道 VM3 有付费扩展,但我没有资源。

4

1 回答 1

0

您应该使用以下设置创建一个新的自定义字段:

Custom Field Type: String
Title: File
Layout position: file

然后将以下代码放入:(templates/*your_template/html/com_virtuemart/productdetails/default.php复制自:components/com_virtuemart/sublayouts/customfields.php和自定义位置)。

$product = $this->product;
$position = 'file';
$class = 'product-fields';  

if (!empty($product->customfieldsSorted[$position])) {
    $custom_title = null;
    foreach ($product->customfieldsSorted[$position] as $field) {
        if ( $field->is_hidden ) //OSP http://forum.virtuemart.net/index.php?topic=99320.0
        continue;
        ?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
            <?php if (!$customTitle and $field->custom_title != $custom_title and $field->show_title) { ?>
                <span class="product-fields-title-wrapper"><span class="product-fields-title"><strong><?php echo vmText::_ ($field->custom_title) ?></strong></span>
                    <?php if ($field->custom_tip) {
                        echo JHtml::tooltip ($field->custom_tip, vmText::_ ($field->custom_title), 'tooltip.png');
                    } ?></span>
            <?php }
            if (!empty($field->display)){
                ?><div class="product-field-display"><a href="images/stories/virtuemart/pdf/<?php echo $field->display; ?>">pdf file</a></div><?php
            }
            if (!empty($field->custom_desc)){
                ?><div class="product-field-desc"><?php echo vmText::_($field->custom_desc) ?></div> <?php
            }
            ?>
        </div>
    <?php
        $custom_title = $field->custom_title;
    }
}
?>

pdf文件必须添加到images/stories/virtuemart/pdf/文件夹中。

于 2015-04-16T18:12:42.640 回答