I know this isn’t a Smarty forum but Smarty is an essential part of Flatpress. I was thinking about how to display the size of documents in the Static Page List and discovered variable modifiers in Smarty. So I added a bit to admin\panels\static\admin.static.list.tpl:

<td>{$content|count_words}<br>{$content|count_characters}</td>

with a happy smile. It didn’t work. Neither count_words nor count_characters work with long files, and having a two megabytes static page results in an allocation error in either modifier. So I rewrote both. (Top remarks omitted here, I didn’t change them.)

fp-includes\smarty\plugins\modifier.count_words.php:

function smarty_modifier_count_words($string)

{

/*

// split text by ' ',\r,\n,\f,\t

$split_array = preg_split('/\s+/',$string);

// count matches that contain alphanumerics

$word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);

return count($word_count);

*/

// Long file aware version by LAttilaD

$string=str_replace(' ', ' ', $string, $spaces);

$string=str_replace("\n", "\n", $string, $enters);

return $spaces+$enters;

}

I know this version isn’t as accurate as the old one, but it won’t stop at a longer file.

(or the same with characters) in your template. The comma is the separator, change it to any character you need. Note that I had to write [0-9] three times because Smarty doesn’t accept {3} as regex pattern (it tries to translate it to a variable).