Blog Sections Open
`sizeof`: A Small Evolution CMS Snippet for Human-Readable File Sizes
Sometimes the right solution is a tiny helper snippet: calculate the file size once and print it in a format editors and visitors can actually read.
Small utility snippets were a big part of the old Evolution ecosystem. One good example is sizeof, a tiny helper that reads a file path and returns a human-readable size.
The Original Use Case
The snippet was designed for cases where a file TV pointed to a downloadable document and the template needed to show the file size next to the link.
[[sizeof? &path=`[*tex-doc*]`]]
with coming from a file-type TV.
The Core Logic
<?php
function format_size($size) {
$metrics = array('', 'KB', 'MB', 'GB', 'TB');
$metric = 0;
while (floor($size / 1024) > 0) {
++$metric;
$size /= 1024;
}
return round($size, 1) . ' ' . (isset($metrics[$metric]) ? $metrics[$metric] : '??');
}
if (file_exists($path)) {
$output = format_size(filesize($path));
}
return $output;
Why This Was Useful
- download links become more informative
- editors do not need to enter file sizes manually
- the display stays correct when files are replaced
This is a good example of the kind of small focused helper that made template output feel more polished without adding unnecessary complexity.
Choosing Between ShopModx, miniShop2, and Shopkeeper
A historical comparison of three ecommerce directions and the architectural trade-offs teams weighed when planning a store on Evolution or Revo.
Thinking About PayPal Express Checkout for Shopkeeper Projects
A historical ecosystem note on connecting PayPal Express Checkout to Shopkeeper and why payment integration decisions should stay modular.