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:
@@ -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.
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user