php menu active probleem

Gestart doorMarjolein12 reacties62 weergaven

13 berichten · pagina 1 van 1

Marjolein

Lid · Topicstarter

Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik ben dus met een menu bezig hypocrite
Maar ik stuit dus op een probleem, ik werk met $_GET[p] dus al mijn paginas worden geopend in mijn indexpagina. Maar ik wil dus ook een active menu... like this:

<a href="index.php" [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/basename"]basename[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]PHP_SELF[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]"index.php"[/COLOR][COLOR= #007700]){[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"class=active"[/COLOR][COLOR= #007700]; }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"class=link"[/COLOR][COLOR= #007700]; }[/COLOR] ?> >HOME</a>


Voor mijn HOME werkt dit prima maar niet voor me andere links omdat die OOK met index.php beginnen bv index.php?p=contact
Weet iemand een oplossing?

Dit werkt dus niet:

<a href="index.php?p=contact" [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/basename"]basename[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]PHP_SELF[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]"index.php?p=contact"[/COLOR][COLOR= #007700]){[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"class=active"[/COLOR][COLOR= #007700]; }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"class=link"[/COLOR][COLOR= #007700]; }[/COLOR] ?> >CONTACT</a>
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
<a href="index.php?p=contact" [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/basename"]basename[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]HTTP_HOST[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]"index.php?p=contact"[/COLOR][COLOR= #007700]){[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"class=active"[/COLOR][COLOR= #007700]; }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"class=link"[/COLOR][COLOR= #007700]; }[/COLOR] ?> >CONTACT</a>


werkt dit?
0
Marjolein

Lid · Topicstarter

Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
nope, werkt ook niet sadley
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
<a href="index.php?p=contact" [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]contact[/COLOR] [COLOR= #007700]?[/COLOR] [COLOR= #DD0000]class="active"[/COLOR] [COLOR= #007700]:[/COLOR] [COLOR= #DD0000]class="link"[/COLOR][COLOR= #007700]);[/COLOR] ?>> >CONTACT</a>


Try this pompom
0
Marjolein

Lid · Topicstarter

Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
pffff, het werkte wel half, maar als ik nu een derde link erbij zet dan bugt het weer sadleyHij zet dan contact en info (= 3e link) allebei op class=active.
Ik snap er echt niks van... confused
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
(isset($_GET[p]) == contact

Moet denk
(isset($_GET[p]) && $_GET[p] == contact

Edit: Weet het bijna zeker want isset geeft true / false yummie
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Inderdaad, dat was ik vergeten. emo
0
Marjolein

Lid · Topicstarter

Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
oke, dat is al beter ja smileMaar nog 1 probleem hypocrite
Als ik op de pagina contact of info ben (dus de 2e of 3e link) dan blijft HOME nog steeds op active staan. Kan dit nog opgelost worden?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Ja met de volgende code:

<a href="index.php?p=contact" [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]]) ||[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]home[/COLOR] [COLOR= #007700]?[/COLOR] [COLOR= #DD0000]class="active"[/COLOR] [COLOR= #007700]:[/COLOR] [COLOR= #DD0000]class="link"[/COLOR][COLOR= #007700]);[/COLOR] ?>> >Homepage</a>


Dus als er geen ?p is, ?p= (dus niks) of ?p=home
0
Marjolein

Lid · Topicstarter

Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oehhh, dank jullie wel
Afbeelding
Hijs perfect nu pompom
0
Marjolein

Lid · Topicstarter

Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oehhh, dank jullie wel
Afbeelding
Hijs perfect nu pompom
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Ok nice biggrin
Veel succes nog smile
PS: Dubbelposten mag niet sadley
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Geen probleem smile
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren