Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    placing a menu in External SS

    HI,

    I am relatively new to CSS. I can create very basic, basic css.

    I am using dreamweaver right now, in an effort to speed up the creation of the site. I am creating it for a non-profit organization. I used dreamweaver to create horizontal (drop down) menu bar. It automatically creates an external .css file but only for the attributes. The actually html - buttons and their links are still in the main page.

    My objective:

    This site is going to grow dramatically in the next year with information, right now it isn't even up on the web, I have to, I am setting it up for potentially a 40 - 50 page site.


    The problem right now is if all the html button data is on a page, each and every page, then every time I update the site I have to edit each and every page, to add a new link.

    I want to put the link menu bar in its own .css file so all I have to do is update that one file and all the pages will be updated.

    Any help would be greatly appreciated.

    Thanks in advance

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,789
    Thanks
    6
    Thanked 1,022 Times in 995 Posts
    CSS means “cascading stylesheet”, not “put my HTML in there to repeatingly include it on random pages”. CSS is styling HTML, not embedding it, and styling is the only thing CSS ca do. The actual HTML has to stay in the HTML file(s).

    Now, there is a way, though. However, it depends on whether their server where the site is on supports it.

    At first the simple solution: Dreamweaver has a very good search and replace function where you can replace the menu on all pages where it occurs in one second. You just copy the old menu, press “Ctrl + F” (“Apple + F” on Mac), choose “Find in: Folder”, “Search: Source Code”, paste it in the upper field, change the menu on the current page, copy and paste it in the lower field of the search, and then click replace all. Everywhere where the old menu appears exactly as on the current page you were working on, it will replace it with the new one.

    That’s for the manual solution without server action, now to the other one:

    There are different functions for different programming languages which basically do all the same, though. This function is called “include”. The most popular language is PHP since it’s open source and available on most servers:

    You create a new file (extension can be “htm(l)”, “php”, “txt”, or whatever) where you just put the code for the menu. Nothing else, just the menu HTML. From the original file(s) where your content is you cut out the menu and replace it with this statement:
    Code:
    <?php include('menu.htm'); ?>
    Now the important thing is that you change the file extension of these files to php because otherwise the server wouldn’t know that that file contains PHP code and would just print it out as it is.

    You do this change to all your pages, i. e. replace the menu on all pages with this include statement. You just need that one menu.htm, though, since you’ll include it on all pages, and if you change that one file, it’ll be changed on all pages immediately.

    You upload both, the menu.htm and the [page].php file(s) to the server and look at the source code, and you’ll see that it looks like there has never been two separate files. PHP just puts them together and nobody will ever know they have been separate.

    Note that PHP is a server side language and you can’t see the results if you preview the file on your local computer (without having a testing server installed).

  • #3
    New Coder
    Join Date
    Jul 2008
    Location
    Newcastle, UK
    Posts
    92
    Thanks
    3
    Thanked 7 Times in 5 Posts
    You can't put HTML in Stylesheets.
    You would need a little basic, basic PHP in there.

    PHP Code:
    <?php include('menu.php'); ?>
    But the page you are putting the include on must have the .php file extension, or it will not work.

    Moodle.

    Edit: Didn't realise VIPStephan's Post
    Beyond Moodle

  • #4
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, I thank you all for your help.

    I do realize you can't put html in the css. Which is why I asked for help. I know, I don't know enough. I am good with html. CSS I am learning. When I learn this, I will move onto another. I think I will go to PHP next.

    Unless someone can recommend the next best thing to move onto after CSS besides PHP.

  • #5
    New Coder
    Join Date
    Jul 2008
    Location
    Newcastle, UK
    Posts
    92
    Thanks
    3
    Thanked 7 Times in 5 Posts
    Javascript. It can add a lot more accessibility & some sweet effects into sites.
    Beyond Moodle


  •  

    Posting Permissions

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