idfile variable not being picked up in template due to scope issues.