Results 1 to 9 of 9

Thread: Side menus

  1. #1
    Join Date
    Nov 2006
    Posts
    116
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Side menus

    Hi Guys,

    I'm looking for a simple vertical menu which should appear on selected pages on my site. I also would like that in order to change something in the menu's but to change it on only one file and it automatically changes on all the pages.

    Cheers

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You could do this using Javascript and using one .js file shared in different pages. However, this is not a good idea because your site's navigation would then be based in Javascript.

    The best idea is for you to use a serverside language to include the menu in all of the pages. The simplest answer might be SSI (serverside includes), but PHP is another option that would be helpful. You could also use a more complicated templating approach or you could use a CMS if you want that much control.

    Of course you will have to still find a menu, but this answers your question about how to include it in every page.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Nov 2006
    Posts
    116
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Hi there,

    Thanks for your help. I thing is i want these menus on some pages only. Not all the pages. Im already using examplemenu from DD on all the pages. Any example would be nice.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Here's an example using PHP:

    PHP Code:
    <?php include('../path/to/my/menu.htm'); ?>
    That will take the contents of the included page and basically "copy and paste" them into the current page, each time it loads. So just change the menu.htm page and it will update all of them.
    Of course if you only want this on some pages then just put that code on the pages where you want the menu-- no reason it would appear on any others.


    Here are a few notes:
    1. Any pages that use that PHP code to include the menu must have a .php extension. (The menu page can be .htm or .php.) .php is the PHP extension and it means that PHP code will be processed first then it will be sent to the browser as HTML (just like a .htm file). [You can set your server to parse .htm files as .php files if you really want, but it's complicated. And not usually that helpful.]
    2. If that menu requires any external Javascript or CSS files, you will need to deal with those on every page as well. This is why templating might be a good idea, but that's not easy for your first project using PHP. The simplest answer is to create two files to include, one called "menu.htm" and another called "menuhead.htm". In the first, write the HTML as you want it in the body of your page and include that page into the body of any page where you want the menu. Then in the menuhead page write the tags to use the .js and .css files, then include that into the <head> section of any page where you want to use the menu. As long as each page includes both, everything should be synchronized.
    3. For any links or shared external files, use absolute paths, not local paths:
    Local path: mypage.htm or ../mypage.htm
    Absolute path: http://my site.com/mypage.htm
    Short absolute path: /mypage.htm [This is a good trick: using the first slash only you use the base of your current domain, but it's less to type.]
    4. To use PHP you must have it installed/enabled on your server. You could do this same method (changing a few things here and there, but the same ideas) with ASP.NET, CGI, SSI (server side includes-- perhaps the easiest), or any other available serverside language that allows 'including' files or an equivalent.


    I hope that helps you get started.


    If all of this sounds too complicated you could use iframes. Not a great solution, but certainly the easiest.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Nov 2006
    Posts
    116
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Hi Djr33,

    Thank you very much for your help. but is there anything simple like the HV menu which i can copy and change the text? Do you know any out there?

    Thank you very much

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Do you want to copy it to each page manually (so that updating it requires updating every page)? If not you will need to do what I have described above, or something similar to it. The method I described is simple, at least compared to some other options out there for doing serverside templating. (I know it may seem confusing if you're not used to it, but it will make sense once you try it and learn how it all works.)
    As I said above, if you don't want to deal with that you could use iframes.

    The only other alternative is using Javascript to generate the menu including its contents. The problem with this is that Javascript is not entirely reliable. This means that if someone has Javascript disabled (or for some reason the script happens to be incompatible with a certain browser) the user will see nothing. For that reason, relying on Javascript for navigation is a very bad idea.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Nov 2006
    Posts
    116
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Hi djr33,

    Below is the link to one of my pages which has got 2 spry menus. i have the same menu on several other pages. I have tried unsuccessfully to make my menu as PHP and include it into this page. Can you please help me and show me what has to be done?

    https://www.elsema.com/12Sv1.htm

    I have followed the eg here but still was not successful! do i have to upload all the files to my server to test or can i see them on my local server?

    http://forums.adobe.com/message/2887613

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    First, all pages that use PHP must end with .php, not .htm.

    (Technically, you can change the server behavior to treat all .htm pages as .php, but that's not a good idea.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. The Following User Says Thank You to djr33 For This Useful Post:

    Bornfree (05-18-2011)

  10. #9
    Join Date
    Nov 2006
    Posts
    116
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Thanks i think i got it working.

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
  •