highlight current page

This is a discussion on "highlight current page" within the Web Page Design section. This forum, and the thread "highlight current page are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack (1) Thread Tools
  #1 (permalink)  
Old Feb 1st, 2008, 22:26
unitedcraig's Avatar
SuperMember

SuperMember
Join Date: Oct 2007
Location: Stockport
Age: 17
Posts: 825
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
highlight current page

Hi again people,

This is a really basic question, but how, through CSS, do i get the current page to highlight in the menu bar?

http://adamsworldbeertour.freehostia.com/ , this is the sort of thing that i mean.

Code: Select all
/**NAVIGATION**/

#navigation {
    float: right;
    width: 300px;
    margin-right: 0px;
}

#navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#navigation ul li {
    float: left;
    width: 100px;
    padding-top: 20px;
}

#navigation ul li a {
    display: block;
    height: 40px;
    text-transform: uppercase;
    color: #000;
    border-bottom: 5px solid #ff99cc;
    text-decoration: none;
    font-weight: bold;
    text-align: center;
    margin-right: 32px;
    padding-top: 5px;
    letter-spacing: 1px;
    font: 10px Tahoma, Geneva, sans-serif;
}

#navigation ul li a.last {
    margin-right: 0;
}

#navigation ul li a:hover {
    background-color: #FF99cc;
    border-bottom: 5px solid #ff99cc;
    color: #fff;
}

#navigation ul li a.current {
    background-color: #FF99cc;
    border-bottom: 5px solid #FF6699;
    color: #fff;
}
Thanks in advance for your help
__________________
Last Blog Entry: A Royal Mistake (Feb 20th, 2008)
Reply With Quote

  #2 (permalink)  
Old Feb 1st, 2008, 22:38
unitedcraig's Avatar
SuperMember

SuperMember
Join Date: Oct 2007
Location: Stockport
Age: 17
Posts: 825
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

http://www.webforumz.com/css-forum/6...rrent-page.htm

Just found this post, i am producing this site possibly for use as a free template, should i find a way with the php script, or do the manual way suggested here?

Edit - if anyone has a php script for this could they please post it

thanks
__________________
Last Blog Entry: A Royal Mistake (Feb 20th, 2008)

Last edited by unitedcraig; Feb 1st, 2008 at 22:42.
Reply With Quote
  #3 (permalink)  
Old Feb 1st, 2008, 23:09
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

Hi Craig

Quote:
How to highlight the current page Nav link ?

Just found this post, i am producing this site possibly for use as a free template, should i find a way with the php script, or do the manual way suggested here?
I posted that thread, but wasn't able to highlight the active tab manually using the code provided, probably you and everyone else can though!? Yes I would like the PHP script also.

Cheers
Reply With Quote
  #4 (permalink)  
Old Feb 2nd, 2008, 10:09
SuperMember

SuperMember
Join Date: Jun 2007
Location: uk
Posts: 459
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

you could take a look here.

http://www.crucialwebhost.com/blog/y...ht-navigation/

not sure if this is what you are looking for

cheers

Pat
Reply With Quote
  #5 (permalink)  
Old Feb 2nd, 2008, 13:32
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

Yes, that is a good link, can you tell me if this looks correct.

Code: Select all
  <ul>
    <li><a<? if($page == 'one') print ' class="active"'; ?> href="/">Welcome</a></li>
    <li><a<? if($page == 'two') print ' class="active"'; ?> href="#" rel="dropmenu1">Classes</a></li>
    <li><a<? if($page == 'three') print ' class="active"'; ?> href="contact.php">Contact</a></li>
    <li><a<? if($page == 'four') print ' class="active"'; ?> href="images.php">Images</a></li>
    <li><a<? if($page == 'four') print ' class="active"'; ?> href="links.php">Links</a></li>
    <li><a<? if($page == 'four') print ' class="active"'; ?> href="coming.php">Events</a></li>
    <li><a<? if($page == 'four') print ' class="active"'; ?> href="#" rel="dropmenu2"> FAQs</a></li>
    <li class="end"><a<? if($page == 'four') print ' class="active"'; ?>href="risadinha.php">The Teacher</a></li>
    </ul>
Reply With Quote
  #6 (permalink)  
Old Feb 2nd, 2008, 14:00
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

Quote:
Yes, that is a good link, can you tell me if this looks correct.
Ok, forget that, I have seen a big mistake in the code.
Reply With Quote
  #7 (permalink)  
Old Feb 2nd, 2008, 14:42
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,266
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: highlight current page

I've done a tutorial on it which might help
http://jackfranklin.co.uk/single.php?contentid=22
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #8 (permalink)  
Old Feb 2nd, 2008, 16:15
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

Great I am on to it!

Cheers Jack
Reply With Quote
  #9 (permalink)  
Old Feb 2nd, 2008, 16:17
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,266
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: highlight current page

No worries, leave a comment if you like it, or if you have any trouble.
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #10 (permalink)  
Old Feb 2nd, 2008, 16:48
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

It seems very simple, I copied and pasted your example in to my page:
Code: Select all
<ul>
<li<?php if ($page == 'home') { echo ' id="active"'; }?>><a href="/">Home</a></li>
<li<?php if ($page == 'classes') { echo ' id="active"'; }?>><a href="#" rel="dropmenu1">Classes</a></li>
<li<?php if ($page == 'events') { echo ' id="active"'; }?>><a href="capoeira-events-up-coming.php">Events</a></li>
<li<?php if ($page == 'contat') { echo ' id="active"'; }?>><a href="capoeira-school-contact.php">Contact</a></li>
<li<?php if ($page == 'teacher') { echo ' id="active"'; }?>><a href="capoeira-school-risadinha.php">The Teacher</a></li>
<li<?php if ($page == 'images') { echo ' id="active"'; }?>><a href="capoeira-school-images.php">Images</a></li>
<li<?php if ($page == 'faq') { echo ' id="active"'; }?>><a href="#" rel="dropmenu2">Capoeira FAQs</a></li>
</ul>
but if you take a look at the screen shot it's a bit messed up?

<?php $page = 'home'; ?> was also added bellow the html tag
Attached Images
File Type: jpg scshot-nav.jpg (27.5 KB, 6 views)

Last edited by Oak; Feb 2nd, 2008 at 16:52.
Reply With Quote
  #11 (permalink)  
Old Feb 2nd, 2008, 17:13
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,266
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: highlight current page

I cannot see what the problem is! Explain?
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #12 (permalink)  
Old Feb 2nd, 2008, 18:12
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

Well, the nav bar has been put out of place/upset by the php code, and > is visible on each nav link.

here is a shot of how the nav bar should look.
Attached Images
File Type: jpg sreenshot-nav2.jpg (25.1 KB, 4 views)
Reply With Quote
  #13 (permalink)  
Old Feb 2nd, 2008, 18:14
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,266
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: highlight current page

It is out of place because of the extra '>' but I've tested the code and I don't get any extra '>'. Could I see the entire code please and/or a link to the webpage?
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #14 (permalink)  
Old Feb 2nd, 2008, 18:20
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

sure!

www.capoeiracanal.co.uk/index.nav.php
Reply With Quote
  #15 (permalink)  
Old Feb 2nd, 2008, 18:21
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

Hang on, that's strange! when viewing the page live, the nav bar looks fine? I had only viewed it in the browser when doing tests in DW
Reply With Quote
  #16 (permalink)  
Old Feb 2nd, 2008, 18:23
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,266
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: highlight current page

Thought so. If you want to test PHP locally, you should read:http://creativecoding.webforumz.com/...ips-tricks/#q3
You could leave a comment on my blog if you like

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #17 (permalink)  
Old Feb 2nd, 2008, 18:32
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

Yes, I will leave a comment for sure!

did you take a look at the source? The active nav is still not highlighted ? Do I need to add any styles to it?

Thanks
Reply With Quote
  #18 (permalink)  
Old Feb 2nd, 2008, 18:43
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,266
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: highlight current page

Oh yes sorry now you go and add your CSS style in the CSS sheet.
Code: Select all
#active {
background-color: blue;
...
}
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #19 (permalink)  
Old Feb 2nd, 2008, 18:50
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 257
Thanks: 0
Thanked 0 Times in 0 Posts
Re: highlight current page

Ok! will leave comment shortly!
Reply With Quote
  #20 (permalink)  
Old Feb 2nd, 2008, 19:00
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,266
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: highlight current page

Nice thanks Oak, and glad I could help
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
Reply

Thread Tools

Posting 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
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.webforumz.com/web-page-design/64775-highlight-current-page.htm
Posted By For Type Date
chromestyle nav/highlight active page IE problem - Dynamic Drive Forums This thread Refback Apr 26th, 2008 17:49

Similar Threads
Thread Thread Starter Forum Replies Last Post
Current page problems unitedcraig Web Page Design 3 Jun 10th, 2008 20:44
After login: Redirect to page in history (Current - 2)... skuliaxe PHP Forum 4 Feb 20th, 2008 16:54
highlight the current page of a drop down menu Oak Web Page Design 2 Feb 12th, 2008 03:08
How to highlight the current page Nav link ? Oak Web Page Design 11 Jan 20th, 2008 13:21
Indicating current page on navigation bar masonbarge PHP Forum 2 Oct 30th, 2006 19:40


All times are GMT. The time now is 05:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved