1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Improved URL matching for layout detection. Closest match will always be used.

This commit is contained in:
Cameron
2019-07-02 09:00:43 -07:00
parent 8e331152e0
commit 53bc1f58b4

View File

@@ -366,6 +366,7 @@ class e_theme
$def = ""; // no custom pages found yet. $def = ""; // no custom pages found yet.
$matches = array();
if(is_array($cusPagePref) && count($cusPagePref)>0) // check if we match a page in layout custompages. 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) foreach($cusPagePref as $lyout=>$cusPageArray)
{ {
@@ -437,13 +439,21 @@ class e_theme
if (!empty($kpage) && (strpos($c_url, $kpage) !== false)) // partial URL match 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. if($def) // custom-page layout.
{ {