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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSS/HTML Vertical Menu

    I am developing a website with several pages with more to be added. Is there a way to develop the menu list in an attached file (such as a .css) so I can edit or add to the menus by editing this one file and have it reflected in all the pages, without having to recode (edit) each individual page?

    Any help would be greatly appreciated.
    Mike

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Not sure how much help this will be, but ...

    I use the Smarty Template Engine, not specifically for the use you describe, but it is a perfectly valid use for smarty.

    I'd create the page header and page footer as separate template files (html). The header file contains everything from "<!DOCTYPE HTML PUBLIC ..." down through the end of the markup that will remain the same on all pages. The footer file contains all the markup that will remain constant across all pages, down through "</html>".

    Then separate template files are created for each page. These files contain all the page content between the header and footer. Then the Smarty 'include' function is used to include the header/footer templates.

    So, something like this:

    body.tpl
    Code:
    {include file="header.tpl"}
    
    ... all page content goes here
    
    {include file="footer.tpl"}
    Then anytime you need to change the header, you simply edit the header.tpl file and the change is reflected site-wide.

    The use of .tpl extension is personal preference - it's perfectly valid to use the .htm file extension if you prefer.

    This may be a bit overkill for your use, but it is one option (I use this method since most pages I design contain dynamic content).

    Hope this makes sense.

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,667
    Thanks
    22
    Thanked 1,826 Times in 1,810 Posts
    Quote Originally Posted by bigmike7844 View Post
    I am developing a website with several pages with more to be added. Is there a way to develop the menu list in an attached file (such as a .css) so I can edit or add to the menus by editing this one file and have it reflected in all the pages, without having to recode (edit) each individual page?

    Any help would be greatly appreciated.
    Mike
    Hello Mike,
    I use a .php include for menus all the time to do exactly what your wanting.
    Have a look at http://www.w3schools.com/php/php_includes.asp
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #4
    Regular Coder
    Join Date
    May 2004
    Location
    San Jose, CA
    Posts
    388
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's all about PHP includes. I originally read this on A List Apart. That's a good read and should get you all set up. This is a priceless method and I can't imagine maintaining a site without it now. I use them all over the place.
    -ts
    -Challenge The Status Quo
    -www.toddseal.com/rodin


  •  

    Posting Permissions

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