category template logic for cats and subcats