Web Hosting Talk


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Link 'selected'
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.

 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-03-2008, 08:26 PM
JustinSmall JustinSmall is offline
View Beta Profile
Aspiring Evangelist
 
Join Date: Jan 2005
Location: North-East, Indiana
Posts: 417
Link 'selected'

With 8+ years in web development, it's hard to believe I don't know everything

Anyways, I have it setup

header
index
footer


of course the index includes the header and footer, but I want to make the links have a predetermined styled for each page.

With the header, it's kind of confusing me, because with the navigation built into the index page instead of the header I could just do 'class="selected"' but I can't now bc it's included...

how could I do this without putting the navigation into the index file itself

__________________
• PHP5 / MySQL / CUSTOM TEMPLATING / CLEAN & MAINTAINABLE CODING
• WEB DEVELOPMENT via CUSTOM DESIGN / PROGRAMMING


Reply With Quote
Sponsored Links
  #2  
Old 10-03-2008, 11:41 PM
Xeentech Xeentech is offline
View Beta Profile
Web Hosting Master
 
Join Date: Aug 2005
Location: UK
Posts: 650
Is the markup generated? PHP say?

If so, you could detect the REQUEST_URI Environment variable in your header script. That should be available everywhere.

Reply With Quote
  #3  
Old 10-04-2008, 12:19 AM
JustinSmall JustinSmall is offline
View Beta Profile
Aspiring Evangelist
 
Join Date: Jan 2005
Location: North-East, Indiana
Posts: 417
Are you referring to do an if statement regarding whether the page is what the link wants it to be???

example
PHP Code:
function link_home() {
    if (
$_SERVER['SCRIPT_NAME'] == '/index.php') {
    print(
"<a href='index.php' class='selected'>Home</a>");
    } else {
    print(
"<a href='index.php'>Home</a>");
    }


__________________
• PHP5 / MySQL / CUSTOM TEMPLATING / CLEAN & MAINTAINABLE CODING
• WEB DEVELOPMENT via CUSTOM DESIGN / PROGRAMMING


Reply With Quote
Sponsored Links
  #4  
Old 10-04-2008, 12:23 AM
Xeentech Xeentech is offline
View Beta Profile
Web Hosting Master
 
Join Date: Aug 2005
Location: UK
Posts: 650
That's what I was thinking, did I misunderstand what you were after?

You could also set some variable (globally) before you include the header, depending on your server side language.

Reply With Quote
  #5  
Old 10-04-2008, 08:00 AM
JustinSmall JustinSmall is offline
View Beta Profile
Aspiring Evangelist
 
Join Date: Jan 2005
Location: North-East, Indiana
Posts: 417
I could do this, seems like a lot of code though lol

__________________
• PHP5 / MySQL / CUSTOM TEMPLATING / CLEAN & MAINTAINABLE CODING
• WEB DEVELOPMENT via CUSTOM DESIGN / PROGRAMMING


Reply With Quote
  #6  
Old 10-04-2008, 01:57 PM
ThatScriptGuy ThatScriptGuy is offline
View Beta Profile
Web Hosting Master
 
Join Date: Feb 2003
Location: AR
Posts: 2,119
How is it a lot of code? Instead of

PHP Code:
include 'header.php'
you have
PHP Code:
$page='Home';
include 
'header.php'
or if you're using smarty
PHP Code:
{include file="header.tpl" page="Home"

__________________
Kevin Cackler
That Script Guy
(479) 437-9874

Reply With Quote
  #7  
Old 10-04-2008, 02:00 PM
JustinSmall JustinSmall is offline
View Beta Profile
Aspiring Evangelist
 
Join Date: Jan 2005
Location: North-East, Indiana
Posts: 417
I'm not using Smarty ATM.

I've figured it out, thanks though.

__________________
• PHP5 / MySQL / CUSTOM TEMPLATING / CLEAN & MAINTAINABLE CODING
• WEB DEVELOPMENT via CUSTOM DESIGN / PROGRAMMING


Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement: