Has anyone else experienced the problem that there doesn't seem to be a per-region counter in PHPtemplate in 4.7, or is it some kind of weird hallucination of mine?

If anyone else is looking for it, here is my template.php file to expose such a variable, based on the classic manual pages Making additional variables available to your templates and Regions in PHPTemplate

 function _phptemplate_variables($hook, $vars) {
    static $regioncount;
    if ($hook == 'block') {
        $region = $vars['block']->region;
        $regioncount = is_array($regioncount) ? $regioncount : array();
        $regioncount[$region] = is_int($regioncount[$region]) ? $regioncount[$region] : 1;
        $vars['regioncount'] = $regioncount;
        $regioncount[$region]++;
    }
    return $vars;
} 

then... a simple
print $regioncount[$block->region];

in the block.tpl.php will summon up the block region sequence.

Hope it saves someone else some woes.

Comments

Greg Go’s picture

Thank you dan90!

--

Wise Bread - a community blog