Commit b0bce37c by Scott

Refactor navigation selected items code

parent 802f6879
...@@ -236,21 +236,31 @@ ...@@ -236,21 +236,31 @@
global $qa_template; global $qa_template;
$requestlower=strtolower(qa_request()); $requestlower = strtolower(qa_request());
// Set appropriate selected flags for navigation (not done in qa_content_prepare() since it also applies to sub-navigation) // Set appropriate selected flags for navigation (not done in qa_content_prepare() since it also applies to sub-navigation)
foreach ($qa_content['navigation'] as $navtype => $navigation) foreach ($qa_content['navigation'] as $navtype => $navigation) {
if (is_array($navigation) && ($navtype!='cat')) if (!is_array($navigation) || $navtype == 'cat') {
continue;
}
foreach ($navigation as $navprefix => $navlink) { foreach ($navigation as $navprefix => $navlink) {
$sel = false;
if (isset($navlink['selectpaths'])) { if (isset($navlink['selectpaths'])) {
// match specified paths
foreach ($navlink['selectpaths'] as $path) { foreach ($navlink['selectpaths'] as $path) {
if (strpos($requestlower.'$', $path) === 0) if (strpos($requestlower.'$', $path) === 0)
$qa_content['navigation'][$navtype][$navprefix]['selected'] = true; $sel = true;
} }
} }
elseif ($requestlower === $navprefix || $requestlower.'$' === $navprefix) elseif ($requestlower === $navprefix || $requestlower.'$' === $navprefix) {
$qa_content['navigation'][$navtype][$navprefix]['selected'] = true; // exact match for array key
$sel = true;
}
$qa_content['navigation'][$navtype][$navprefix]['selected'] = $sel;
}
} }
// Slide down notifications // Slide down notifications
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment