that is already too much logic for a view, in my taste.
If you need that information, get it in the controller