Jump to content

One menu for whole site?


gotmedia

Recommended Posts

I know it's possible, I'm just not sure how.

 

I have a sidebar, and in certain sections, the sidebar menu changes.

 

I want to say "when you are in THIS section, show THIS menu" (in the sidebar).  How would I go about doing that? :)

 

 

Link to comment
Share on other sites

Okay cool!

 

Would this work:

 

<?php
if ($dir == "media") {
echo '<div class="menu">
<ul>
<li> <a href="/media/">media</a> </li>
<li> <a href="/media2/">media 2</a> </li>
<li> <a href="/media3/">media 3</a> </li>
</ul>
</div>'
}

else if ($dir == "about") {
echo '<div class="menu">
<ul>
<li> <a href="/about/">about</a> </li>
<li> <a href="/about2/">about 2</a> </li>
<li> <a href="/about3/">about 3</a> </li>
</ul>
</div>'
}

else if ($dir == "extras") {
echo '<div class="menu">
<ul>
<li> <a href="/extras/">extras</a> </li>
<li> <a href="/extras/">extras</a> </li>
<li> <a href="/extras/">extras</a> </li>
</ul>
</div>'
}
?>

 

I think it's pretty close?

Link to comment
Share on other sites

Oh okay, then this right?

 

<?php
if ($_SERVER['media']) {
echo '<div class="menu">
<ul>
<li> <a href="/media/">media</a> </li>
<li> <a href="/media2/">media 2</a> </li>
<li> <a href="/media3/">media 3</a> </li>
</ul>
</div>'
}

else if ($_SERVER['about']) {
echo '<div class="menu">
<ul>
<li> <a href="/about/">about</a> </li>
<li> <a href="/about2/">about 2</a> </li>
<li> <a href="/about3/">about 3</a> </li>
</ul>
</div>'
}

else if ($_SERVER['extras']) {
echo '<div class="menu">
<ul>
<li> <a href="/extras/">extras</a> </li>
<li> <a href="/extras/">extras</a> </li>
<li> <a href="/extras/">extras</a> </li>
</ul>
</div>'
}
?>

 

As read in the link you gave me, it would be ($_SERVER['/public_html/extras/']) since they want the absolute pathname, correct?

Link to comment
Share on other sites

sorry, you'll want something like this... you'll have to base the menu of the current file name or something... which $_SERVER['SCRIPT_FILENAME'] will tell you...

 


<?php

$current_page = basename($_SERVER['SCRIPT_FILENAME']);

if ($current_page == 'media.php') {
echo '<div class="menu">
<ul>
<li> <a href="/media/">media</a> </li>
<li> <a href="/media2/">media 2</a> </li>
<li> <a href="/media3/">media 3</a> </li>
</ul>
</div>';
}

else if ($current_page == 'about.php') {
echo '<div class="menu">
<ul>
<li> <a href="/about/">about</a> </li>
<li> <a href="/about2/">about 2</a> </li>
<li> <a href="/about3/">about 3</a> </li>
</ul>
</div>';
}

else if ($current_page == 'extras.php') {
echo '<div class="menu">
<ul>
<li> <a href="/extras/">extras</a> </li>
<li> <a href="/extras/">extras</a> </li>
<li> <a href="/extras/">extras</a> </li>
</ul>
</div>';
}
?>

 

... should work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.