简体   繁体   English

VirtueMart将文件(pdf)添加到产品

[英]VirtueMart add file(pdf) to product

I'm trying to add a pdf file in my products via an input field in the admin product page, in the description section. 我正在尝试通过管理产品页面“说明”部分中的输入字段在我的产品中添加pdf文件。 For now I've created the field (product_file) in the view part and it sends the attached pdf. 现在,我已经在视图部分中创建了字段(product_file),并发送了随附的pdf。 My issues is that I don't know exactly where the form sends the params and I can't assign my product_file field to save the name as a string in the database and at the same time to save the file as pdf in a folder in the main directory. 我的问题是我不知道表单将参数发送到哪里,也无法分配product_file字段将名称另存为数据库中的字符串,同时也无法将文件另存为pdf到文件夹中。主目录。 I work with Joomla 3.4.1 and Virtuemart 3.0.6.4. 我使用Joomla 3.4.1和Virtuemart 3.0.6.4。 Any advice is greatly appreciated. 任何意见是极大的赞赏。

ps I know that there is paid extension for VM3, but I do not have the resources for that. ps我知道VM3有付费扩展,但是我没有足够的资源。

You should create a new custom field with these settings: 您应该使用以下设置创建一个新的自定义字段:

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

Then put the following code to the: templates/*your_template/html/com_virtuemart/productdetails/default.php (copied from: components/com_virtuemart/sublayouts/customfields.php and customized position). 然后将以下代码放入: 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;
    }
}
?>

The pdf file has to be added to images/stories/virtuemart/pdf/ folder. pdf文件必须添加到images/stories/virtuemart/pdf/文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM