Thanks Rolf, I also thought about something like this but neither did I get my nor your code to work.
I modified your code example like so in my UDT called “filesize”:
Code: Select all
// read parameters
$path = isset($params['path']) ? $params['path'] : '';
// check if file exists
if(file_exists($path))
{
$filesize = filesize($path);
// beautify filesize
$suffix = "B"; // for Bytes
if($filesize > 1024)
{
$filesize = $filesize / 1024;
$suffix = "KB";
if($filesize > 1024)
{
$filesize = $filesize / 1024;
$suffix = "MB";
if($filesize > 1024)
{
$filesize = $filesize / 1024;
$suffix = "GB";
}
}
}
$filesize = sprintf("%.2f", $filesize);
// edit this line, if you want a different representation of your link
echo $filesize.$suffix;
}
else
{
// this is shown if the file you try to link can't be found
echo 'n.v.';
}
In the LISE template I’m doing this:
Code: Select all
{foreach $items as $item}
{$filename=$item->fielddefs.datei}
{assign var="file_path" value=$item->fielddefs.datei->GetImagePath(true)|cat:"/":$filename}
…
{filesize path=$file_path}
And despite the fact that the file is there and the path correctly points to it, the code in the UDT appears to return false for the file_exists() function.
I’m kind of at a loss.