Computer Science Canada

making a menu...

Author:  Myst [ Sat Feb 16, 2008 12:43 pm ]
Post subject:  making a menu...

so i basically made my own site, its looks nice and i want to add content to it soon buuuut, I dont want to go through the hassle of always updating links in the Menu everytime i add a new page to it. So i was wondering if there is some way to make my menu its own html file, insert it into another html document and then when i add a new page all i would have to do is edit that one file instead of going through all of the other html documents just to add a links.

Thanks in advance.

Author:  milton.ignites [ Mon Feb 18, 2008 4:17 pm ]
Post subject:  RE:making a menu...

you cud use a frame.. but i think there are more efficent ways to script it. (that i dotn know how ... lol)

Author:  Myst [ Mon Feb 18, 2008 4:20 pm ]
Post subject:  RE:making a menu...

ummm i dont want to use frames. So ya a different way would be nice ^_^

Author:  HeavenAgain [ Mon Feb 18, 2008 4:32 pm ]
Post subject:  RE:making a menu...

i think php scripts is what you are looking for... or java scripts? one of those........

Author:  rdrake [ Mon Feb 18, 2008 4:38 pm ]
Post subject:  RE:making a menu...

PHP (or just about any server-side language) would do it easily but would require said language on the server. JavaScript would work too so long as the user has JS turned on in their browser. The problem with JS, though, is not necessarily that the user will turn it off but rather that IE6 (under XP SP2) and IE7 could potentially block it from doing anything useful.

Author:  Myst [ Mon Feb 18, 2008 5:32 pm ]
Post subject:  RE:making a menu...

ah i see thanks, can you guys link me to a tutorial for this?

Author:  rdrake [ Mon Feb 18, 2008 7:35 pm ]
Post subject:  RE:making a menu...

Most certainly. You use that function to include your menu code wherever you please.

Author:  Myst [ Mon Feb 18, 2008 9:24 pm ]
Post subject:  RE:making a menu...

ummm i dont know that function xD im kinda of a noob at PHP....

Author:  rdrake [ Mon Feb 18, 2008 9:49 pm ]
Post subject:  Re: making a menu...

Exactly the reason why I pointed you to that function.

All you do is this:

php:

<html>
  <!-- Stuff before the menu goes here. -->

  <?php
    include("menu.php");
  ?>

  <!-- Stuff after the menu goes here. -->
</html>
That's all there is to it.

Author:  Myst [ Mon Feb 18, 2008 9:55 pm ]
Post subject:  RE:making a menu...

really thats it? amazing! ^_^

so basically i copy my menu to a php file so my
php file should look like this:

<head>
<body>
<!--Menu-->
</body>
</head>

and then i do the above code into my (x)html document correct?

Author:  rdrake [ Mon Feb 18, 2008 11:48 pm ]
Post subject:  RE:making a menu...

Not quite, you don't need the head nor body tags in there. You need just the code required to display the menu.

Think of using the include as cutting out a chunk of the file than pasting it back in there later. In this way you can modify the menu all you want and it'll be inserted back into the file once the page is served again later. This seems to be what you want.

Author:  Myst [ Tue Feb 19, 2008 5:08 pm ]
Post subject:  RE:making a menu...

ya this is what i want ^_^ but i presume since im using PHP that all of my pages would also have to be PHP in order to use this code no?

Author:  rdrake [ Tue Feb 19, 2008 5:25 pm ]
Post subject:  Re: RE:making a menu...

Myst @ Tue Feb 19, 2008 5:08 pm wrote:
ya this is what i want ^_^ but i presume since im using PHP that all of my pages would also have to be PHP in order to use this code no?
For the sake of simplicity, yes.

Author:  Myst [ Tue Feb 19, 2008 6:23 pm ]
Post subject:  RE:making a menu...

im sorry if i bothered u for such simple questions, I should have just have knew the above answer by logic xD


: