Fix incorrect sidebar conditions on 2-2-stable branch

Change 'defined?' check to 'defined and not nil' condition to prevent partials from being called when no valid data is available.

See #155 for fix in master.