Jump to content

how to display product attachment filesize?


aaront1

Recommended Posts

Who said it isn't possible :rolleyes:

 

in your ProductController.php file, assign a new smarty variable to define prestashop download directory

$this->context->smarty->assign('download_dir' , _PS_DOWNLOAD_DIR_);

and then in your product.tpl file, modify the content of attachments block like this :

    {* NOTE: we assign a new smarty vars: $filePath(a path to file), $fileSize(attachment fileseze in Kb) *}
    {if isset($attachments) && $attachments}
        <ul id="idTab9" class="bullet">
        {foreach from=$attachments item=attachment}
            {assign var=filePath value=$download_dir|cat:$attachment.file}
            {assign var=fileSize value=($filePath|@filesize)/1024}
            <li><a href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")}">{$attachment.name|escape:'htmlall':'UTF-8'} <strong>({$fileSize|number_format:2:'.':','} {l s='Kb'})<strong></a><br />{$attachment.description|escape:'htmlall':'UTF-8'}</li>
        {/foreach}
        </ul>
    {/if}

 

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...