Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Menu disabling recursive links

Menu disabling recursive links
Thread Tools
- - e r i k - -
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Jan 9, 2006, 11:09 PM
 
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?

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
jay3ld
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Jan 9, 2006, 11:53 PM
 
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. )
     
- - e r i k - -  (op)
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Jan 10, 2006, 01:00 AM
 
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. )

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
- - e r i k - -  (op)
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Jan 10, 2006, 01:12 AM
 
Ah, I might be able to make sense of that edited code. Let me give it a try.

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
- - e r i k - -  (op)
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Jan 10, 2006, 01:28 AM
 
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]

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
jay3ld
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Jan 10, 2006, 02:03 AM
 
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
     
- - e r i k - -  (op)
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Jan 11, 2006, 11:49 PM
 
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]

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
jay3ld
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Jan 12, 2006, 12:33 AM
 
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
     
- - e r i k - -  (op)
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Jan 12, 2006, 01:58 AM
 
Yeah, that was what I was doing first too

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:55 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,