Fixed fatal errors caused by the missing "query" field in layout_page
Added search query where needed.
If "query" var does not exist in request, display empty