[英]VirtueMart add file(pdf) to product
我正在嘗試通過管理產品頁面“說明”部分中的輸入字段在我的產品中添加pdf文件。 現在,我已經在視圖部分中創建了字段(product_file),並發送了隨附的pdf。 我的問題是我不知道表單將參數發送到哪里,也無法分配product_file字段將名稱另存為數據庫中的字符串,同時也無法將文件另存為pdf到文件夾中。主目錄。 我使用Joomla 3.4.1和Virtuemart 3.0.6.4。 任何意見是極大的贊賞。
ps我知道VM3有付費擴展,但是我沒有足夠的資源。
您應該使用以下設置創建一個新的自定義字段:
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/
文件夾中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.