navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Active Page when linking from Page includes

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Cascading Style Sheets >> Active Page when linking from Page includes
Page: [1]
 
Avick

 

Posts: 181
From: Ireland
Status: offline

 
Active Page when linking from Page includes - 9/6/2006 11:00:41   
Just a question I have been curious about.

When designing with style sheets is it possible to show a page as active if the link is coming from a page include.

Example:
Link 1 Link2 Link3

I want to change the style on Link2 when the visitor is on that page. As the pages are coming from a page include, I have nothing on the actual page to mark with a tag such as id=active

Can this be done using just CSS or is it just out of the question!


_____________________________

Alan
http://www.newebirl.net
Tailslide

 

Posts: 6003
Joined: 5/10/2005
From: Out here on the raggedy edge
Status: offline

 
RE: Active Page when linking from Page includes - 9/6/2006 11:33:36   
Easiest thing to do is to assign an id to every page within the body element e.g.

<body id="home">


Then in your include, add an id to every nav item like this:

<ul>
<li><a href="whatever.html" id="nav-home">Home</a></li>
<li><a href="whatever1.html" id="nav-contact">Contact</a></li>
</ul>


Then you can specify a rule within your stylesheet to apply only to the particular nav item id when you're on a page with a certain id like this:
#home #nav-home, #contact #nav-contact {font-weight:bold;}


_____________________________

"My strategy is so simple an idiot could have devised it"
Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project

(in reply to Avick)
caz

 

Posts: 3518
Joined: 10/10/2001
From: Somewhere south of Chester, UK
Status: offline

 
RE: Active Page when linking from Page includes - 9/6/2006 11:59:34   
As far as I am aware tailslide's solution is the best one to use to make FP do what you want. It works for me. :)

_____________________________

Do not meddle in the affairs of cats, for they are subtle and will dance, or more on your keyboard.
Cheshire cat. www.doracat.co.uk

I remember when it took less than 4hrs to fly across the Atlantic.

(in reply to Tailslide)
Avick

 

Posts: 181
From: Ireland
Status: offline

 
RE: Active Page when linking from Page includes - 9/6/2006 15:26:27   
Thanks Tailslide,
Took me a bit to get my head around but I got there in the end.

Just to make sure I understand what I am trying to do,
Each page is looking for not one but to unique identifiers before it will apply the style???

The first (#home) sets up the boundry for when the second tag comes along (#nav-home)
Similar to the effect if I put a p inside a class like so:

.box p {}
any paragraph under the box style will get the formats set out in the specified p style.

I hope I have it right, otherwise I got a headache for nothing :)

_____________________________

Alan
http://www.newebirl.net

(in reply to caz)
Tailslide

 

Posts: 6003
Joined: 5/10/2005
From: Out here on the raggedy edge
Status: offline

 
RE: Active Page when linking from Page includes - 9/6/2006 16:16:18   
That sounds about right to me - it's all about specificity - the rules only apply when you've got both ids together on a page. That way you don't need to worry about trying to set up different classes on each active page - a single include with all your nav in it is all you need - just be sure that you give all the pages a specific id.

The only thing I ever find is a problem is remembering to write out the CSS rule properly - bearing in mind that it can get quite long - inevitably I leave off a hash somewhere down the line!

_____________________________

"My strategy is so simple an idiot could have devised it"
Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project

(in reply to Avick)
Avick

 

Posts: 181
From: Ireland
Status: offline

 
RE: Active Page when linking from Page includes - 9/7/2006 5:27:11   
I now have two different sets of styles for two different types of menus

I have been tinkering around with the layout to see if I could make it a bit easer to find what I am looking for when editing the tags. I stacked the tags on top of each other and it worked quite well and it validated.

#home #nav-home, 
#portfolio #nav-portfolio, 
#services #nav-services, 
#standards #nav-standards, 
#sitemap #nav-sitemap
{color: #006; border-bottom: 2px solid #006;}


I find this just makes it a little easer to read!

_____________________________

Alan
http://www.newebirl.net

(in reply to Tailslide)
Tailslide

 

Posts: 6003
Joined: 5/10/2005
From: Out here on the raggedy edge
Status: offline

 
RE: Active Page when linking from Page includes - 9/7/2006 6:59:45   
You're probably right. For reasons I can't quite explain I started writing all my CSS rules out on one line. I find it easier to read but everyone else in the world finds it confusing and difficult to read... so obviously I'm right and everyone else in the world is wrong! :)

_____________________________

"My strategy is so simple an idiot could have devised it"
Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project

(in reply to Avick)
Avick

 

Posts: 181
From: Ireland
Status: offline

 
RE: Active Page when linking from Page includes - 9/7/2006 7:04:48   
LOL :)



_____________________________

Alan
http://www.newebirl.net

(in reply to Tailslide)
Page:   [1]

All Forums >> Web Development >> Cascading Style Sheets >> Active Page when linking from Page includes
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts