Blog Sections Open

A Small PHx Declension Helper for Comment Counts and Similar UI Labels

A tiny utility pattern for Russian plural endings that paired naturally with PHx placeholders.

Some of the most useful Evo helpers were tiny. This declension snippet is a good example: it solved a very practical UI problem by choosing the correct word ending based on a number, such as comment counts in a Ditto or Jot listing.

Used together with a placeholder like [+jotcount+], it let templates output linguistically correct labels without repeating condition logic everywhere.

Example usage

комментари[+jotcount:declension=`й|я|ев`+]

Core snippet logic

$data = explode('|', trim($options));
$num = $output;
$res = $data[0];
if ($num % 10 > 1 && $num % 10 < 5) $res = $data[1];
if ($num % 10 > 4 || $num % 10 == 0) $res = $data[2];
if ($num % 100 > 10 && $num % 100 < 20) $res = $data[2];
return $res;

It is a small helper, but it shows the kind of polish developers were adding to Evo templates long before richer localization layers became common.

Newer post

ManagerManager 0.3.11: New Widgets and Dashboard Fixes

A release-style extras note covering ManagerManager 0.3.10–0.3.11 improvements, including new widgets, bug fixes, and better manager-side automation.