【问题标题】:VirtueMart add file(pdf) to productVirtueMart 添加文件(pdf)到产品
【发布时间】:2015-06-20 06:07:07
【问题描述】:

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

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

【问题讨论】:

    标签: php pdf joomla virtuemart joomla3.4


    【解决方案1】:

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

    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/文件夹中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-01
      • 1970-01-01
      • 2018-08-03
      • 1970-01-01
      • 2013-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多