Download file link in page list block

Permalink
Hello, I was wonder how I would go about creating a download link that would retrieve a file from the file manger in the page list block.

These are the steps that I taken so far..

I've created a custom attribute $downloadLink = $page->getAttribute('download_link');

I'm calling it like
<div class="ordernow">
      <a class="btn btn-primary" href="<?php echo $downloadLink ?>"     target="_blank">Download</a>
      </div>
.)
It does create the button and display, however, it does not download the thumbnail. I've even tried
<div class="ordernow">
      <a class="btn btn-primary" href="<?php echo $downloadLink ?>"     target="_blank" download>Download</a>
      </div>
.)

That's not working either.

 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi brushelt,

You can try something like this:
<?php
// get the file attribute object
$downloadLink = $page->getAttribute('download_link');
// if the file attribute object is true, display the link HTML
if ($downloadLink) { ?>
    <div class="ordernow">
        <!-- use the getDownloadURL() method to get the download URL -->
        <a class="btn btn-primary" href="<?php echo $downloadLink->getDownloadURL(); ?>" target="_blank">Download</a>
    </div>
<?php } ?>