aaront1 Posted October 10, 2013 Share Posted October 10, 2013 Hi, On the product page, is there a way to display the attachment filesize? in other words, where can I get and add the filesize and set it to a variable, so that the product.tpl can display that value? Link to comment Share on other sites More sharing options...
vekia Posted October 11, 2013 Share Posted October 11, 2013 you use default prestashop features to attach files to products? if so, unfortunately it isn't possible. Only after modification of the Product class (and attachment class probably too) Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted October 11, 2013 Share Posted October 11, 2013 Who said it isn't possible 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 More sharing options...
vekia Posted October 11, 2013 Share Posted October 11, 2013 doesnt work: Link to comment Share on other sites More sharing options...
aaront1 Posted October 11, 2013 Author Share Posted October 11, 2013 it works for me. I put the smarty->assign line inside the initContent function on my ProductController.php file. Thanks a lot. 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