[ticket/11675] Fix template loop

http://tracker.phpbb.com/browse/PHPBB3-11675