|
|
Menu disabling recursive links
|
|
|
|
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status:
Offline
|
|
I want my site to be as easily updateable as possible and have made the navigation menu separate and used a php-include (not using any CMS for this one). But then I lose one of the important web design principles: Never have a link to the same page.
Is there a way (through php or JS, preferably the former), to make the menu "know" what page it is on and disable the recursive link?
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
the only thing i can think of going off the top of my head is
[php]
<?php
$WereAreWe = $_SERVER["PHP_SELF"];
$cssmenu = $yourcssmenuhtmlcodehere
$cssmenu = str_replace($WereAreWe, '# ', $cssmenu);
echo $cssmenu;
?>
[/php]
you might be able to do something similar in javascript and that way you could grab the parent tag (A) and delete the whole tag. but i am having trouble remembering that way.
but this way just deletes the link and makes it # so it does nothing.
edit
well im having trouble while im testing it so it may not work
edit2
well this way works
[php]
<?php
$WereAreWe = $_SERVER["PHP_SELF"];
$cssmenu = ''; // just to set the variable
if ($WereAreWe != '/1.php'){$cssmenu .= '<a href="/1.php">Link One</a>'; } else { $cssmenu .= 'Link One'; }
if ($WereAreWe != '/Gsig.php'){$cssmenu .= '<a href="/Gsig.php"> Gsig </a>'; } else { $cssmenu .= 'Gsig'; }
if ($WereAreWe != '/recursivelink.php'){$cssmenu .= '<a href="/recursivelink.php"> Recursive Link </a>'; } else { $cssmenu .= 'Recursive Link'; }
if ($WereAreWe != '/Pspell2.php'){$cssmenu .= '<a href="/Pspell2.php"> Pspell </a>'; } else { $cssmenu .= 'Pspell'; }
echo $cssmenu;
?>
[/php]
(
Last edited by jay3ld; Jan 10, 2006 at 12:08 AM.
)
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status:
Offline
|
|
While that would help a bit, it still would make it an active link though.
And I'm still not entirely sure how to graft the php-snippet onto my existing menu code, which is as simple as this:
[html]<div id="navMeny">
<a href="OmOss.php" title="Om Selskapsspesialisten">OM OSS</a>
<a href="Lokaler.php" title="Våre selskapsslokaler på Jessheim og Gardermoen">LOKALER</a>
<a href="Catering.php" title="Våre cateringmuligheter">CATERING</a>
<a href="Menyer.php" title="Noen ekssempler på hva vi kan tilby">MENYER</a>
<a href="Jul.php" title="Julebord? Sjekk våre deilige julemenyer">JUL</a>
<a href="Kontakt.php" title="Ring oss for prisanslag og bestillinger">KONTAKT</a></div>[/html]Bear in mind that the most advanced thing I've done in php is includes and figuring out how to combine a seasonal changing css-script and a user defined php-styleswitcher (which I'm rather proud of )
(
Last edited by - - e r i k - -; Jan 10, 2006 at 01:10 AM.
)
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status:
Offline
|
|
Ah, I might be able to make sense of that edited code. Let me give it a try.
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status:
Offline
|
|
That worked perfectly! Thanks a lot! It's already in action at www.selskapsspesialisten.no
[php]<div id="navMeny">
<?php
$WereAreWe = $_SERVER["PHP_SELF"];
$cssmenu = ''; // just to set the variable
if ($WereAreWe != '/OmOss.php'){$cssmenu .= '<a href="/OmOss.php" title="Om Selskapsspesialisten">OM OSS</a>'; } else { $cssmenu .= '<p>OM OSS</p>'; }
if ($WereAreWe != '/Lokaler.php'){$cssmenu .= '<a href="/Lokaler.php" title="Våre selskapsslokaler på Jessheim og Gardermoen">LOKALER</a>'; } else { $cssmenu .= '<p>LOKALER</p>'; }
if ($WereAreWe != '/Catering.php'){$cssmenu .= '<a href="/Catering.php" title="Catering. Service, ikke bare mat">CATERING</a>'; } else { $cssmenu .= '<p>CATERING</p>'; }
if ($WereAreWe != '/Menyer.php'){$cssmenu .= '<a href="/Menyer.php" title="Sjekk våre ferdiglagde menyer eller kom med egne ønsker">MENYER</a>'; } else { $cssmenu .= '<p>MENYER</p>'; }
if ($WereAreWe != '/Kontakt.php'){$cssmenu .= '<a href="/Kontakt.php" title="Ring oss for prisanslag og bestillinger">KONTAKT</a>'; } else { $cssmenu .= '<p>KONTAKT</p>'; }
echo $cssmenu;
?></div>[/php]
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
glad you got it working. i was trying to find out why the first code never worked. it should of worked to replace that whole string and disabled the link but never worked... and glad to see you now know a little more php.
i got the $_SERVER["PHP_SELF"]; from my head but if you make a php page and put in it <? phpinfo(); ?> it will show your whole server then scroll down near bottom has php variables and thats were you can get some others as well
which can do some cool things
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status:
Offline
|
|
In my quest for learning php and having to do as little admining on this page as possible, I added a Christmas-menu item (Jul.php) that would only appear from October through December. This should work, right? (it parses just fine):[php]<?php
$WereAreWe = $_SERVER["PHP_SELF"];
$cssmenu = ''; // just to set the variable
if ($WereAreWe != '/OmOss.php'){$cssmenu .= '<a href="/OmOss.php" title="Om Selskapsspesialisten">OM OSS</a>'; } else { $cssmenu .= '<p>OM OSS ›</p>'; }
if ($WereAreWe != '/Lokaler.php'){$cssmenu .= '<a href="/Lokaler.php" title="Våre selskapsslokaler på Jessheim og Gardermoen">LOKALER</a>'; } else { $cssmenu .= '<p>LOKALER ›</p>'; }
if ($WereAreWe != '/Catering.php'){$cssmenu .= '<a href="/Catering.php" title="Catering. Service, ikke bare mat">CATERING</a>'; } else { $cssmenu .= '<p>CATERING ›</p>'; }
if ($WereAreWe != '/Menyer.php'){$cssmenu .= '<a href="/Menyer.php" title="Sjekk våre ferdiglagde menyer eller kom med egne ønsker">MENYER</a>'; } else { $cssmenu .= '<p>MENYER ›</p>'; }
if(date("n") >= 10 && date("n") <= 12) {if ($WereAreWe != '/Jul.php'){$cssmenu .= '<a href="/Jul.php" title="Julecatering">JUL</a>'; } else { $cssmenu .= '<p>JUL ›</p>'; };
}
if ($WereAreWe != '/Kontakt.php'){$cssmenu .= '<a href="/Kontakt.php" title="Ring oss for prisanslag og bestillinger">KONTAKT</a>'; } else { $cssmenu .= '<p>KONTAKT ›</p>'; }
echo $cssmenu;
?>[/php]
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
Originally Posted by - - e r i k - -
In my quest for learning php and having to do as little admining on this page as possible, I added a Christmas-menu item (Jul.php) that would only appear from October through December. This should work, right? (it parses just fine):
doing some alterations i get it to show it works
[php]
if(date(n) >= 1 && date(n) <= 2) {
if ($WereAreWe != '/Jul.php')
{$cssmenu .= '<a href="/Jul.php" title="Julecatering">JUL DATE ONLY FUNCTION</a>'; }
else { $cssmenu .= '<p>JUL ›</p>'; }
}
[/php]
so yea that is working
i just changed the dates their so it would find it in our month
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status:
Offline
|
|
Yeah, that was what I was doing first too
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|