Forum for discussing general topics related to Couch.
11 posts Page 1 of 2
i already implemented your file_size.php Addons and set path in kfunction.php in Addons folder, but it shows error


here is code
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Downloads' name='downloads' clonable='1' commentable='0' dynamic_folders='1'>
<cms:editable name='file_name' label='File Name' type='text' />

<cms:editable name='download_description' label='Download Description' type='text' />

<cms:editable
name='my_filesize'
type='hidden'
validator='FileSize::get'
assoc_field='file_download'
>0</cms:editable>



<cms:editable
  name='file_download'
  label='Downloadable File'
  desc='Upload the file here'
  type='file'
/>

</cms:template>
<cms:if k_is_page >
<cms:else />
   <cms:embed 'downloads.html' />
</cms:if>
<?php COUCH::invoke(); ?>



Here Downloads.html File

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><cms:get_custom_field 'downloads' masterpage='globals.php' /> | <cms:get_custom_field 'site_name' masterpage='globals.php' /></title>
<meta name="keywords" content="<cms:get_custom_field 'meta_tag' masterpage='globals.php' />" />
<meta name="description" content="<cms:get_custom_field 'meta_desc' masterpage='globals.php' />" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
function clearText(field)
{
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}
</script>


</head>
<body>
<cms:embed 'header.html' />

<div id="slider_wrapper_n">
       <h2><cms:get_custom_field 'downloads' masterpage='globals.php' /></h2>
        <p><cms:get_custom_field 'downloads' masterpage='assets.php' /></p>
   </div>
       
    <div id="templatemo_main">
   
   <div class="col_w900 col_w900_last">
   <h3>Downloads List</h3>
          <center><table class="imagetable">
       
<tr>
   <th><font color="white">Sr No</font></th><th><font color="white">File Name</font></th><th><font color="white">Description</font></th><th><font color="white">Size</font></th><th><font color="white">Download</font></th></tr>
<cms:pages masterpage='downloads.php'>
<tr>
   <td><center><cms:show k_count/></center></td><td><cms:show file_name/></td><td><cms:show download_description/></td><td><center><cms:show my_filesize /></center></td><td><div class="download_link"><a href="<cms:show file_download/>" ><b>Download</b></a></div><br></td>
</tr>
</cms:pages>
</table></center>
            <div class="cleaner"></div>
     </div>
       
        <div class="cleaner"></div>
       
        <span class="bottom"></span>    </div>

<cms:embed 'footer.html' />
</body>
</html>
<?php COUCH::invoke(); ?>


When i try to upload file from admin panel its saying 1error their
Hi :)
You must remove these 2 lines, because they are needed only for standalone templates, and since you already have all that in the template, there is no need to repeat it. Here you simply embed a snippet, which is a html piece of code. It is the same as pasting the whole content of download.html to the original file in place of 'embed'. So these lines are not needed with any snippets. Make sure you don't have them either in your header.html and footer.html.
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<?php COUCH::invoke(); ?>


What does the error say actually? Where do you experience it?
@trendoman when i upload any file fro admin panel their it saying one error,i followed your process


here is code i use

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Downloads' name='downloads' clonable='1' commentable='0' dynamic_folders='1'>
<cms:editable name='file_name' label='File Name' type='text' />

<cms:editable name='download_description' label='Download Description' type='text' />

<cms:editable
name='my_filesize'
type='hidden'
validator='FileSize::get'
assoc_field='file_download'
>0</cms:editable>

<cms:editable
  name='file_download'
  label='Downloadable File'
  desc='Upload the file here'
  type='file'
/>

</cms:template>
<cms:if k_is_page >
<cms:else />
   <cms:embed 'downloads.html' />
</cms:if>
<?php COUCH::invoke(); ?>



but when i remove below code then its upload and working

Code: Select all
<cms:editable
name='my_filesize'
type='hidden'
validator='FileSize::get'
assoc_field='file_download'
>0</cms:editable>


but i want to show filesize, plz help me

Attachments

I am afraid I can't help, because this addon is not working on my setup.
It says no error, but never shows filesize.

If you need it, it is better to go with php command. Look for dynamic param in editables in forum search. There you can place code to show file size.
Or maybe someone else can share a working version.
@vbxlive, I tested out your template and, exactly as @trendoman reported, there were no errors but the filesize always came up as zero.

I changed back the 'type' of the region from 'hidden' to 'text' (as it should be) -
<cms:editable
name='my_filesize'
type='text'
validator='FileSize::get'
assoc_field='file_download'
>0</cms:editable>

And now the code works perfectly for me.

So, I can confirm that (with that one amendment) your code is working for me.
I don't see any cause for the error. Please try uploading different files and see if the error occurs only on certain files. Let us know.

Thanks.
when i removed this hidden to text ,their is validator problem

Attachments

The error message suggests that the validator 'FileSize::get' (implemented in 'filesize.php' available at the original thread https://www.couchcms.com/forum/viewtopic.php?f=8&t=7440) is not found by Couch.

I know you mentioned in your original post that you activated the addon but let us redo things from scratch.

Attached is a zip that contains the 'filesize.php' file. Extract the file and place it in your 'couch/addons/' folder (so that now you have 'couch/addons/filesize.php').

Edit the 'kfunctions.php' file in the same 'couch/addons/' folder (in case 'kfunctions.php' file is not present, rename the 'kfunctions.example.php' to 'kfunctions.php'.) and add the following line to it -
Code: Select all
require_once( K_COUCH_DIR.'addons/filesize.php' );


Now try uploading a new file and see if the validator kicks in.

As I already mentioned, the code above is tried and tested. In case things still do not work for you, I suggest you go ahead and complete your site ignoring the error. Once you deploy your site and make it online, if the error persists let us know and I'll login to see what the problem is.

Attachments

Hi, I've downloaded and registered the filesize add-on. Tried to use it inside a repeatable but with no success, however, changed the structure to page and now filesize is displayed both at admin and front-end. However, when records are filled in, it seems that the value for the first record is set to 0, while succeeding entries seem ok. Thanks
Hello. I stumbled upon this article (an a few others) for showing the size of uploaded files. I am showing the size on the front-end (listed with a downloadable file). I am using this in an editable region and it seems to be working fine for one entry (or the most recent entry)... but then each new row I add to the editable region, the previous rows file size field resets to 0. Wondering if this is able to be implemented within an editable region, and if so, how to keep the file size value to remain (not default to 0) in each row after adding more rows.

Thanks!


Sam
WorthDesignCo.com
Sounds like that editable type is "repeatable region"? Addon filesize doesn't understand such situation, it is coded to work with simpler editable fields. If you need filesize in admin panel, the Mosaic with simpler fields will work fine, each tile taking path to one file i.e. without repeatable. Worth a try using Mosaic for this one.

Hey, getting a file size is a very-very quick op, it is quite okay (in my view) to print file size on front-end immediately. Still quick even if there are 100s of files in the list. That's what I would have done to keep files comfortably in a repeatable in Admin panel and print sizes on front-end. I published a func "show-size" (github) that does the job well, even with more features.

WorthDesign wrote: Hello. I stumbled upon this article (an a few others) for showing the size of uploaded files. I am showing the size on the front-end (listed with a downloadable file). I am using this in an editable region and it seems to be working fine for one entry (or the most recent entry)... but then each new row I add to the editable region, the previous rows file size field resets to 0. Wondering if this is able to be implemented within an editable region, and if so, how to keep the file size value to remain (not default to 0) in each row after adding more rows.

Thanks!


Sam
11 posts Page 1 of 2