Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: How to have a common menu file

  1. #1
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default How to have a common menu file

    I want to make a non-java menu that I can modify 1 file and have the changes effect all the pages.
    Is this even possible? and if so, how can I do it?

    I currently have a small site with few pages, but I know that can change fast.

    I want to plan ahead by making it easy to add or edit menu options.
    That way I don't have to keep changing every pages menu each time.
    Last edited by Eddie11; 07-22-2011 at 07:18 PM.

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Do you mean a a non-java menu or a a non-javascript menu?
    ===
    Arie Molendijk.

  3. #3
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    java script.

    I was scanning over the hundreds of pages in this forum and found a similar question.

    The answer to that was php

    Is there any code already available for copy paste or is it something I just have to learn how to code php?

  4. #4
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Yes, use php if you don't want to use javascript.
    I'm not a php-expert, but I know how to do php-includes. It's rather easy. But before going into the details: do you want to exclude javascript everywhere, even in the menu?
    ===
    Arie.

  5. #5
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I would like to avoid the use of Java script, yes.

    I have a rather simple menu currently.

    http://epic11.com if you want to see it.

    like a mentioned at start. I only have a few pages currently.

  6. #6
    Join Date
    Jul 2011
    Location
    Lockport, Illinois
    Posts
    35
    Thanks
    4
    Thanked 2 Times in 2 Posts

    Default

    ok i know that you dont want to use javascript but i guarantee you this is an extremely simple fix that i have used for a long time! and it doesnt mess up layouts or anything.

    This Goes in index.html (or any of your other pages) and it goes in place of the code for your navigation menu.
    Code:
     <script language="javascript" type="text/javascript" 
      src="/path to the file/nav.txt"></script>
    this is the code in nav.txt
    Code:
    document.write(' <ul> <li> <a="href:blablabla"> BlaBlaBla </a> </li> <!-- etc etc etc.--> ')
    All of the html code in nav.txt MUST BE ON ONE LINE. Basically dont press enter. your text editor may word wrap it into many lines, but as long as you dont press enter, the browser will treat it as one line.

    That will put your navigation menu into one file that will update to all the pages at the same time.

    Hope this helps!

    -JL Griffin

  7. The Following User Says Thank You to griffinwebnet For This Useful Post:

    Eddie11 (07-22-2011)

  8. #7
    Join Date
    Jul 2011
    Location
    Lockport, Illinois
    Posts
    35
    Thanks
    4
    Thanked 2 Times in 2 Posts

    Default

    Quote Originally Posted by molendijk View Post
    Yes, use php if you don't want to use javascript.
    I'm not a php-expert, but I know how to do php-includes.
    im not entirely sure how you would use a php-includes that would make it A) easy and B) automated.

    you could use it to set up a variable for each link and then set the location in the anchor tag to the value of the included variable. which would theoretically work if he were to change the location of the pages via the included file, however, if he were to add a new page, he would still have to go to each page and add the link to the variable... that would be the simplest way, there are other better ways, but they are WAY too dificult for someone who doesnt know php at all...

    Quote Originally Posted by molendijk View Post
    Yes, use php if you don't want to use javascript.
    Also I Disagree with this statement... php is a server-side scripting language and should be avoided unless necessary... I would have to advise against the use of php for a client side goal like this as it would waste resources... unforutnately javascript is the way to go with this stuff.

    -JL Griffin

  9. #8
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I will give that a try.

    I was told that java script is not a good idea to use for menus because allot of people have java disabled on their browsers.

  10. #9
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Hello griffinwebnet and Eddie11,
    I think there are a couple of things I should make clear here.

    1.
    Including an external file via document.write is a bronze age method that I use myself, but it is still bronze-age and discouraged by many people. This is what http://dev.w3.org/html5/spec/Overvie...document.write says about it:
    This method has very idiosyncratic behavior. In some cases, this method can affect the state of the HTML parser while the parser is running, resulting in a DOM that does not correspond to the source of the document. In other cases, the call can clear the current page first, as if document.open() had been called. In yet more cases, the method is simply ignored, or throws an exception. To make matters worse, the exact behavior of this method can in some cases be dependent on network latency, which can lead to failures that are very hard to debug. For all these reasons, use of this method is strongly discouraged.

    2.
    Php is a server-side scripting language and should therefore be used if possible.

    3.
    Php-includes are easy and automated by definition. I can give you an example if you like.

    4.
    The menu used by Eddie11 is rather simple: no submenus. So Eddie11 can use an iframe on each of his pages to embed his menu. No javascript and no php needed.

    ===
    Arie.

  11. #10
    Join Date
    Jul 2011
    Location
    Lockport, Illinois
    Posts
    35
    Thanks
    4
    Thanked 2 Times in 2 Posts

    Default

    Quote Originally Posted by Eddie11 View Post
    I will give that a try.

    I was told that java script is not a good idea to use for menus because allot of people have java disabled on their browsers.
    that is differant though, there is a differance between JRE and Javascript. Having Java disabled means that java applets wont run, however javascript doesnt use the java framework, all modern browsers have javascript installed and enabled by default. you can see that here:

    http://www.computerhope.com/issues/ch000891.htm

    I use javascript in almost all of my menus nowadays.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •