[greenstone-users] Re: Search Collection Location and KB instead of byes

From Katherine of Greenstone Team
DateMon Mar 16 12:58:24 2009
Subject [greenstone-users] Re: Search Collection Location and KB instead of byes
In-Reply-To (000001c99b17$92bd4380$b837ca80$-net)
Have you got a solution for 1?

You can use javascript:

Add the following into the macro in style.dm:

function format_filesize(bytes) {
var filesize = bytes + " bytes";
if (bytes > 1048576) {
filesize = Math.round(bytes / 1048576.0) + " MB";
}
else if (bytes > 1024) {
filesize = Math.round(bytes/1024.0)+ " kB";
}
document.write(filesize);
}

Then in your format statement, instead of [FileSize] use
<script language="javascript"
type="text/javascript">format_filesize([FileSize])</script>

Hopefully this will work, unless I have a typo :-)

Cheers,
Katherine

DTMartin wrote:
> Hello,
>
> I have two questions.
>
> 1. Is there a format statement that shows KB instead of just bytes? Right
> now my format statement use ([ex.FileSize] bytes) For large files this
> looks cumbersome
>
> 2. When doing a search across collections is there a format feature that
> allows me to display which collection the file came from?
>
> Thanks for your help
>
> Dwight
>
>
>