How to "call" for a file, rather than editing every page.

Discussion in 'HTML & Website Design' started by ian_batten, Feb 10, 2007.

  1. #1
    Okay, I am building a failry simple HTML website, which has lots of information pages. What I want to do, if on these pages, call for a certain file, for the header, footer, and menu, rather than creating it on each page, and when I update, having to edit each page individually.
    How can I do this?
    Thanks in advance!
     
    ian_batten, Feb 10, 2007 IP
  2. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Dan Schulz, Feb 10, 2007 IP
  3. astra

    astra Peon

    Messages:
    53
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Create a template, then build each page from that template. Within that template make an "editable region" where you will put all the content for each individual page. If you need to make a change an item in a menu, for example, you will only need to do it once. Template will automatically upload that change to each page that was created from it.

    astra
     
    astra, Feb 10, 2007 IP
  4. marty

    marty Peon

    Messages:
    154
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey Ian,

    I don't think this solution will be very good from a SEO perspective, but I've had luck with a JavaScript solution.

    You can create a .js file and include it in the top of all of your pages.

    In the JS file you could have functions called printHeader() and printFooter()

    printHeader() and printFooter() could read something like:

    function printHeader(){
    var headerText = "<div id='header'>This is my header</div>"
    document.write(headerText)
    }

    function printFooter(){
    var footerText = "<div id='footer'>This is my footer</div>"
    }


    your HTML could look something like

    <html>
    <head>
    <title>blah</title>
    <script src="your.js"></script>
    </head>
    <body>
    <script language="JavaScript">
    printHeader()
    </script>

    YOUR CONTENT HERE

    <script language="JavaScript">
    printFooter()
    </script>

    </body>
    </html>


    Good luck!!!!
     
    marty, Feb 10, 2007 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Won't do any good if someone's using a screen reader, mobile device or has JavaScript turned off :(.
     
    Dan Schulz, Feb 10, 2007 IP
  6. -NB-

    -NB- Peon

    Messages:
    153
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    PHP for the win.

    <?php
    include 'header.php';
    ?>
    PHP:
     
    -NB-, Feb 10, 2007 IP
  7. unitedrokz

    unitedrokz Peon

    Messages:
    86
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    yep i was just about to say the same thing...

    just create everything in seperate files (as -NB- alluded to with header.php) and then call them in the page

    ie.

    <?php
    include 'header.php';
    ?>
    PHP:
    [/QUOTE]

    you individual page content here

    <?php
    include 'footer.php';
    ?>
    PHP:
    [/QUOTE]
     
    unitedrokz, Feb 10, 2007 IP
  8. ian_batten

    ian_batten Well-Known Member

    Messages:
    1,991
    Likes Received:
    106
    Best Answers:
    0
    Trophy Points:
    185
    #8
    Thank you so much, this was just what I was looking for!
    Works like a dream ;)
    Green added ^^
     
    ian_batten, Feb 11, 2007 IP