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.



 Subscribe in a reader

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

Notices


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

SuperMember
Join Date: Oct 2007
Location: Stockport
Age: 17
Posts: 844
Blog Entries: 1
Thanks: 0
Thanked 1 Time in 1 Post
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

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

SuperMember
Join Date: Oct 2007
Location: Stockport
Age: 17
Posts: 844
Blog Entries: 1
Thanks: 0
Thanked 1 Time in 1 Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Feb 1st, 2008, 23:09
Oak's Avatar
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 304
Thanks: 6
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Feb 2nd, 2008, 10:09
Reputable Member
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Feb 2nd, 2008, 13:32
Oak's Avatar
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 304
Thanks: 6
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>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Feb 2nd, 2008, 14:00
Oak's Avatar
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 304
Thanks: 6
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Feb 2nd, 2008, 14:42
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,402
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: highlight current page

I've done a tutorial on it which might help
http://jackfranklin.co.uk/single.php?contentid=22
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Feb 2nd, 2008, 16:15
Oak's Avatar
Oak Oak is offline
SuperMember

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

Great I am on to it!

Cheers Jack
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Feb 2nd, 2008, 16:17
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,402
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: highlight current page

No worries, leave a comment if you like it, or if you have any trouble.
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Feb 2nd, 2008, 16:48
Oak's Avatar
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 304
Thanks: 6
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Feb 2nd, 2008, 17:13
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,402
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: highlight current page

I cannot see what the problem is! Explain?
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Feb 2nd, 2008, 18:12
Oak's Avatar
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 304
Thanks: 6
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Feb 2nd, 2008, 18:14
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,402
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 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?
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Feb 2nd, 2008, 18:20
Oak's Avatar
Oak Oak is offline
SuperMember

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

sure!

www.capoeiracanal.co.uk/index.nav.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Feb 2nd, 2008, 18:21
Oak's Avatar
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 304
Thanks: 6
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Feb 2nd, 2008, 18:23
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,402
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 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
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old Feb 2nd, 2008, 18:32
Oak's Avatar
Oak Oak is offline
SuperMember

SuperMember
Join Date: Dec 2007
Location: London
Age: 35
Posts: 304
Thanks: 6
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!