If you viewing a topic or post then the $foruminfo[forumid] isn't registered so any if condition involving the forumid won't work. I nearly went bald discovering this recently.
Their might be a plugin someplace which will define the forumid for the topic your viewing and then the code you have above will work. I actually gave up before I found a solution so can't help any more, sorry