From 53bc1f58b44700c9e49ca0ab49e2a3ca6ae11aca Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 2 Jul 2019 09:00:43 -0700 Subject: [PATCH] Improved URL matching for layout detection. Closest match will always be used. --- e107_handlers/theme_handler.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 9c3073e4f..5a6c437b7 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -366,6 +366,7 @@ class e_theme $def = ""; // no custom pages found yet. + $matches = array(); if(is_array($cusPagePref) && count($cusPagePref)>0) // check if we match a page in layout custompages. @@ -391,6 +392,7 @@ class e_theme } }*/ + foreach($cusPagePref as $lyout=>$cusPageArray) { @@ -437,13 +439,21 @@ class e_theme if (!empty($kpage) && (strpos($c_url, $kpage) !== false)) // partial URL match { - $def = $lyout; + similar_text($c_url,$kpage,$perc); + $matches[$lyout] = round($perc,2); // rank the match + // echo $c_url." : ".$kpage." --- ".$perc."\n"; } } } } + if(!empty($matches)) // return the highest ranking match. + { + $top = array_keys($matches, max($matches)); + $def = $top[0]; + //print_r($matches); + } if($def) // custom-page layout. {