Ah, I see. I would be extremely cautious of using code like this because someone could edit that in the future and without knowing it cause some big issues.

Please specify if ($field && in_array($field, array('legend', 'teampage'))) for this section (you can put it first and use else if ($field) for the other part if you'd like).