PDA

View Full Version : is there an easy way to do this?



gnznroses
12-14-2005, 05:14 PM
my site has a menu of items that may change semi-frequently. so, my first instinct was to put the links in a seperate file and include it with SSI. but, i just realized, the menu item for the currently selected page looks different. let me explain: the links have a background image when you mouse over them, and after you click a link and go to that section, then that link's image will always be visible, to show where on the site you are. the selected link is given the new style with an id tag, as shown in the example below:

NORMAL LINK
<TR align=left><TD><A class=mainlevel href="index.shtml">HOME</A></TD></TR>

SELECTED LINK
<TR align=left><TD><A class=mainlevel id=active_menu href="index.shtml">HOME</A></TD></TR>

i'm familiar with CSS and classes, but i've never used IDs so i don't even know how exactly it works, but it makes it so i can't have one file with all these links in it, cause one of the links has to have a special tag added. i doubt it, but is there an easy way to do this?

Chris
12-14-2005, 07:51 PM
The only way I can think of to do it (without any server side code) is javascript after the page has loaded.

Or... you could take the option of not leaving that section on the menu highlighted. I mean, the title of the page, content, and headers, should all let the user know where they are at, why does the menu need to too? Especially when keeping that functionality is causing you a headache.

mark1345
12-14-2005, 10:08 PM
SELECTED LINK
<TR align=left><TD><A class=mainlevel id=active_menu href="index.shtml">HOME</A></TD></TR>

I have found this:
http://www.456bereastreet.com/archive/200503/setting_the_current_menu_state_with_css/

gnznroses
12-14-2005, 10:31 PM
hmm, i'm afraid i don't understand that...

Kate
12-14-2005, 10:50 PM
Are you able to have php in the file? If you are able to have php in the file you could have something like this (all though I am sure there is an easier way to do this in php) -



<?php
$link1 = '/index.shtml';
if ($link1 == $PHP_SELF) {
?>
<TR align=left><TD><A class=mainlevel id=active_menu href="index.shtml">Home</A></TD></TR>
<?php } else { ?>
<TR align=left><TD><A class=mainlevel href="index.shtml">Home</A></TD></TR>
<?php }?>

For each of the links. Then save it as menu.php or something and then where you'd usually have the menu in each of the files, put

<?php include 'menu.php' ; ?> Then when you want to update the menu, you only have to edit menu.php.

gnznroses
12-15-2005, 08:15 PM
Kate that sounds like a good solution. i've never used PHP before, so i'll hafat research how to run it. i'm guessing tho i just name the pages .php and don't need any special ermissions set or anything? oh well, i'll find out.

Cutter
12-16-2005, 12:32 PM
I use the php include that Kate posted above. All you should have to do is add the following line to your .htaccess file:

AddType application/x-httpd-php .htm .html

That will parse all html files as php so you do have to rename anything

If you don't have a .htaccess file, just create I file in notepad and do save as type -- all files.

gnznroses
12-16-2005, 12:43 PM
i've got it up and running. it works great. thanks kate.