Jump to content

Nav Bar: How to make a button show active for each page of your site?


Barons

Recommended Posts

Hi,

 

Sorry if this is in the wrong place. I really just need a search term to use for what i'm trying to do.

 

I would like my buttons to appear pressed on each page. For example if you are on the home page the home button will appear pressed. If you are on the screenshots page the screenshots button will appear pressed. Pretty much i want my nav bar to display what page is being viewed.

 

I'm using SMF forums and i've created an extension of my forum that i'm using on the root of my site. As far as i can tell i have the correct code added to the forum that should highlight the home button while on the home page. The part i'm missing is the code to add onto the home page.

 

This is the code I have on the button.

	$buttons = array(
         'overview' => array(
            'title' => $txt['overview'],
		'href' => 'http://www.wararmada.com',
            'show' => true,
            'sub_buttons' => array(
               'alliance' => array(
                  'title' => $txt['alliance'],
                  'href' => $scripturl . '?action=overview;area=alliance',
                  'show' => true,
               ),

 

 

This is the code i have in the language file.

$txt['overview'] = 'overview';

 

I'm not sure what this is called. I don't know anything about php but so far i've been able to get by just using google but I don't really know how to search for this.

 

Thanks for all the help!

 

Link to comment
Share on other sites

I've not extended SMF at all, but I can tell you the common way to approach this is by dynamically setting the 'class' of the nav items. If you are on the corresponding page for any given item, a class is assigned to the element, which you then style in your css. It is usually ".selected".

 

However, there may be a way SMF does this for you with a simple flag - I'm not sure. I would first go here:

 

http://www.google.co.uk/search?q=php+nav+highlight+selected+&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a

 

You might also try searching for SMF plugins which can do this for you automatically.

 

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.