From 5215adb98de2ae79bbc296c565225203e8181637 Mon Sep 17 00:00:00 2001 From: brettp Date: Tue, 27 Oct 2009 13:54:55 +0000 Subject: Fixes #1161: Views now default to 'default' if not found. git-svn-id: http://code.elgg.org/elgg/trunk@3585 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'engine/lib/elgglib.php') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 2eecfefb6..4ac43e4de 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -238,7 +238,6 @@ function elgg_view($view, $vars = "", $bypass = false, $debug = false, $viewtype } } - // Get the current viewtype if (empty($viewtype)) { $viewtype = elgg_get_viewtype(); @@ -256,27 +255,16 @@ function elgg_view($view, $vars = "", $bypass = false, $debug = false, $viewtype foreach($viewlist as $priority => $view) { $view_location = elgg_get_view_location($view, $viewtype); $view_file = "$view_location$viewtype/$view.php"; + $default_view_file = "{$view_location}default/$view.php"; // try to include view, defaulting to 'default' view if error. - - if (file_exists($view_file) && !include($view_file)) { - $success = false; - - if ($viewtype != "default") { - $default_view_file = "{$view_location}default/$view.php"; - if (file_exists($default_view_file) && include($default_view_file)) { - $success = true; - } - } - - if (!$success) { - elgg_log("The view $view could not be included", 'WARNING'); + if (!file_exists($view_file) || !include($view_file)) { + if ($viewtype != 'default' && file_exists($default_view_file) && include($default_view_file)) { + elgg_log("$viewtype/$view view does not exist. Using default/$view instead.", 'WARNING'); + } else { + elgg_log("Neither $viewtype/$view nor default/$view view exists.", 'WARNING'); } - - } else if (!file_exists($view_file)) { - elgg_log("The view $view does not exist", 'WARNING'); } - } // Save the output buffer into the $content variable -- cgit v1.2.3