use tpl_toc to determine if TOC should be shown

tpl_toc returns NULL if there is no TOC to show so we can change the
grid layout later. Not sure if we could save the tpl_toc return value
then use it later instead of regenerating again to save a bit of time..