Submit Your Article Forum Rules

Results 1 to 6 of 6

Thread: Is there a way to load an external layout on every page?

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    3

    Is there a way to load an external layout on every page?

    Hello there,
    I'm wondering if there is any way to load an entire layout on each page from an external file? As far as I know, this is not possible but I may be working on a site for someone who wants to be able to alter layouts once but having the change(s) be made on all pages.

    Any help is appreciated, thanks for reading.

  2. #2
    Administrator rah's Avatar
    Join Date
    Jul 2003
    Posts
    2,450
    Wouldn't this be the same as all template/css based site designs?

  3. #3
    WebProWorld MVP williamc's Avatar
    Join Date
    Jul 2003
    Location
    On a really big hill in Kentucky
    Posts
    4,721
    an example in php:

    Code:
    <?php include("header.html"); ?>
    
    your page content here
    your page content here
    your page content here
    
    <?php include("footer.html"); ?>
    William Cross
    Web Development by Those Damn Coders
    Firearm Friendly Websites because our constitution matters

  4. #4
    Junior Member
    Join Date
    May 2011
    Posts
    3
    This is why ignoring php has been a terrible decision.
    Thank you for your help, williamc. I'm going to be learning php through w3 and any other resources I can find very soon but I had no idea it could reference external files for its own layout.

    Is it considered amature to have the layout pieces such as navigations or footers written on each page now?
    Also, do I treat "header.html" as its own web page with a head/body/html ect tags?

  5. #5
    WebProWorld MVP williamc's Avatar
    Join Date
    Jul 2003
    Location
    On a really big hill in Kentucky
    Posts
    4,721
    You would treat the header as the top of an html page, and the footer as the bottom basically.

    Ie: header.html could look something like this:

    Code:
    <html>
      <head>
         <title><?php echo $pagetitle; ?></title>
      </head>
      <body>
    footer.html might look like this:

    Code:
      </body>
    </html>
    and your contents page, lets call it index.html might look like this:

    Code:
    <?php
      $pagetitle = 'This is my page title';
      include("header.html");
    ?>
    
    This is my content on this page.<br />
    This is my content on this page.<br />
    This is my content on this page.<br />
    
    <?php include("footer.html"); ?>
    Notice I made the title tag dynamic per page. You can do the same thing for metatags, headings, etc.
    You can use table or css layouts in headers and footer, such as left or right navigational columns, etc.
    William Cross
    Web Development by Those Damn Coders
    Firearm Friendly Websites because our constitution matters

  6. #6
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Wow, web design really changes over the years.
    Thank you for your help!

Tags for this Thread

Posting Permissions

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