Hi, sorry for my English…
I have a PHP file for changing my pages, the Code is this,
<?php
class NavigationLinkList {
private $current_page;
private $arLinks;
public function __construct( $arNewLinks = false ) {
$this -> arLinks = [];
$this -> addLinks ( $arNewLinks );
$this -> current_page = $_SERVER['REQUEST_URI'];
}
public function addLinks ( $arNewLinks ) {
$flagErrors = false;
if ( isset( $arNewLinks['URL'] ) && isset( $arNewLinks['TEXT'] ) ) { #Auf diesen if ,baut der array ...
array_push( $this -> arLinks, $arNewLinks );
return true;
}
if ( is_array ( $arNewLinks ) ) {
foreach ( $arNewLinks as $NewLink ) {
if ( isset( $NewLink['URL'] ) && isset( $NewLink['TEXT'] ) ) {
array_push( $this -> arLinks, $NewLink );
}
}
} else {
$flagErrors = true;
}
return false == $flagErrors;
}
public function printNav() {
echo '
<form class="link_change">
<ul>' . PHP_EOL;
foreach ( $this -> arLinks as $link ) {
if ( $this -> current_page == $link['URL'] ) {
$aria = ' aria-current="page"';
} else {
$aria = '';
}
echo ' <li><a' . $aria . ' href=' . $link['URL'] .'>' . $link['TEXT'] . '</a></li>' . PHP_EOL;
}
echo '
</ul>
</form>' . PHP_EOL;
}
}
$_SERVER['REQUEST_URI'];
$navListe = new NavigationLinkList();
$navListe -> addLinks( [ 'URL' => 'index.php', 'TEXT' => '1' ] );
$navListe -> addLinks( [ 'URL' => 'index2.php', 'TEXT' => '2' ] );
$navListe -> printNav();
I have a File CSS for page change,
.link_change ul {
list-style-type: none;
margin-left: 340px;
}
.link_change li {
display: inline;
}
.link_change a {
display: inline;
text-decoration: none;
border: 1px solid gray;
background-color: #FE2E64;
color: black;
padding: 8px;
opacity: 0.5;
font-family: Times New Roman;
}
.link_change a:hover {
background-color: #9f9e9e;
}
.link_change a[aria-current="page"] {
background-color: green;
}
All working gut, how the Screenshot to show,
my Problem is with
.link_change a[aria-current="page"]
it will not to change the Color…
Can please someone help me to solve this problem, Thanks!