Jump to content

Determine if attachment is PDF or Mp3


Darussalam

Recommended Posts

Hi, I need help with conditional statements to determine if the attachment is a PDF file, Mp3 or any other as I want to display different text on the button depending on the download item. PDF will say, View Sample PDF, Mp3 will say Listen Sample Audio and 'Download Sample' for all others. Will really appreciate any help. Below is my code for downloading product attachments.

 

      <!--Download -->
  {if isset($attachments) && $attachments} 
    {foreach from=$attachments item=attachment name=attachements}
    {if $smarty.foreach.attachements.iteration %3 == 1}
    <div class="row">
      {/if}
        <a class="btn btn-default btn-block" style="font-size: 16px;" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}" target="_blank"> <i class="icon-download"></i> {l s="Download Sample"} ({Tools::formatBytes($attachment.file_size, 2)}) </a>
      {if $smarty.foreach.attachements.iteration %3 == 0 || $smarty.foreach.attachements.last}
    </div>
    {/if}
    {/foreach} 
 {/if}
  <!--end Download --> 

Thank you!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...