Check that navigation section exists before using it for top menu

This is needed as it can be removed from Mediawiki:Sidebar (or from
various extensions).

Change-Id: I34c4264ae3dae2e712fce4a153e153451f460342