Now it works. I extended the code from the theme
Log a bit so that it fits my needs. And here’s my code:
Code: Select all
<ul>
<?php
function umlaute($string) {
$search = array("Ä", "Ö", "Ü", "ä", "ö", "ü", "ß", "´");
$replace = array("Ae", "Oe", "Ue", "ae", "oe", "ue", "ss", "");
return str_replace($search, $replace, $string);
}
foreach ($staticPages as $staticPage) {
if($_SERVER['REQUEST_URI'] == "/".strtolower(umlaute($staticPage->title()))) {
echo '<li class="active"><a href="'.$staticPage->permalink().'">'.$staticPage->title().'</a></li>';
} else {
echo '<li><a href="'.$staticPage->permalink().'">'.$staticPage->title().'</a></li>';
}
}
?>
</ul>
A little explanation:
The function changes German umlauts to normal characters. In the loop, it is checked on which page the user currently is. In case that the page title has umlauts in it, they are changed to normal letters, and also the letters are changed to lowercase, so that the title is exactly the same as the request uri. Now this page is marked as active in the navigation (via CSS). All other pages remain unmarked.