Jump to content

Jules72

New Members
  • Posts

    2
  • Joined

  • Last visited

Jules72's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks, could you explain how to do it? Happy to make a donation! The file names are "XXX-XXXX.pdf" separated by a comma
  2. Code below is used on a Magento 2 website to display a download link for product instructions etc. We have some products that require more than one PDF, we can enter these is the Download attribute (dz_downloads) separated by a comma, but only one displays? If anyone could help amend the code so that we can display more than one PDF download per product it would be appriciated. <?php $product = $block->getProduct(); $blockObj = $block->getLayout()->createBlock('Dzinehub\Core\Block\Main'); $mediaUrl = $blockObj->getMediaUrl().'pdf_upload/'; $BaseUrl = $blockObj->getBaseUrl(); $mediapath = $blockObj->getMediaDir(); $pdfOption = 'dz_downloads'; $pdfoptionvalue = $product->getData($pdfOption); $pdf_files = explode(',', $pdfoptionvalue); foreach ($pdf_files as $pdf_file) { $pdfURL = $mediaUrl."".$pdf_file; $pdfPath = $mediapath .'/pdf_upload/' .$pdf_file; } ?> <?php if($pdf_file != "" && file_exists($pdfPath)){ ?> <div class="dz_pdf"> <a href="<?php echo $pdfURL; ?>" download><?php echo $pdf_file; ?></a> </div> <?php } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.