Darussalam Posted July 21, 2018 Share Posted July 21, 2018 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 More sharing options...
Darussalam Posted July 23, 2018 Author Share Posted July 23, 2018 (edited) Still waiting if someone can help. I want to a statement to check if the $attachment.name contains 'pdf' to display "View Sample PDF'. Searching online but haven't find a solution yet. Edited July 23, 2018 by Darussalam (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now