Can You Make It So The Banners SYNC?

Discussion in 'Web Design and Development' started by JackT06, Aug 6, 2009.

  1. JackT06 macrumors 6502

    JackT06

    Joined:
    Jul 24, 2009
    #1
    What i would like to happen is that everytime i change something on one of my html pages on the banners it changes it to all rather than me having to go through all the pages and change them.

    Many Thanks

    The pictures show how my website is at the moment [​IMG][/IMG]
     
  2. Joined:
    Jun 30, 2009
    #2
    What you want can be accomplished (only) with PHP. You create an HTML file with just the header, and then, using a PHP function (if you're interested, require_once('filename');), you link it into the final web site. There might be a better function, I can't say at the moment. Wordpress uses include_header();, and so on while creating its index.php, but I don't know how that works.
     
  3. JackT06 thread starter macrumors 6502

    JackT06

    Joined:
    Jul 24, 2009
    #3
    would the idea of pannels work because the only bit i really want to change is the bit in the middle. And then on my bar across the top put the link to change the panell?
     
  4. Maxington macrumors 6502

    Joined:
    May 11, 2007
    Location:
    Oshkosh, WI
    #4
    If your using a specific program it depends on what your using.

    For pure webcoding you can create utilize something as the above posted stated and use a PHP include function to dynamically add a file to a page so that once you change the main page it trickles down to the others.
     
  5. JackT06 thread starter macrumors 6502

    JackT06

    Joined:
    Jul 24, 2009
    #5
    Well at the moment im using textmate doing HTML
     
  6. Maxington macrumors 6502

    Joined:
    May 11, 2007
    Location:
    Oshkosh, WI
    #6
    Easy way I have found is create a seperate file:

    banner.php and add your banner code to it as a <div>

    Than on all your webpages reference that file using PHP include statement:

    http://www.w3schools.com/PHP/php_includes.asp

    PHP:
    <?php include("header.php"); ?>
    Than once you change the banner.php file all the subsequent pages will reference those changes dynamically.
     
  7. Joined:
    Jun 30, 2009
    #7
    Let me give you a sample:

    banner.htm
    Code:
    <div>
    <img src="image.png" alt="Image" />
    </div>
    
    index.php
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>TITLE HERE</title>
    <link href="stylesheet.css" rel="stylesheet" type="text/css" media="all" />
    </head>
    <body>
    <?php require_once("banner.htm"); ?>
    
    //The rest of your code goes here
    
    </body>
    </html>
    
    page2.php
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>TITLE HERE</title>
    <link href="stylesheet.css" rel="stylesheet" type="text/css" media="all" />
    </head>
    <body>
    <?php require_once("banner.htm"); ?>
    
    //The rest of your code goes here
    
    </body>
    </html>
    
     
  8. JackT06 thread starter macrumors 6502

    JackT06

    Joined:
    Jul 24, 2009
    #8

    Sorry but i have never used a .php what do i do with them?
     
  9. Joined:
    Jun 30, 2009
    #9
    If your page is index.htm, and you plan to use PHP in it, you'll have to rename it to index.php. It tells the browser the page uses PHP scripting.

    But... why don't you try it yourself?
     
  10. Maxington macrumors 6502

    Joined:
    May 11, 2007
    Location:
    Oshkosh, WI
    #10
    As long as your sever is setup to run PHP scripts (most remote hosting will). All you need to do is make sure your webpages are named

    XYZ.php and not XYZ.htm

    Then include the necessary script on the page. The example above is a good one.
     
  11. JackT06 thread starter macrumors 6502

    JackT06

    Joined:
    Jul 24, 2009
    #11

    Does that mean i can only view it once i have uploaded it to my host?

    unlike HTML where you can just double click on it?
     
  12. Maxington macrumors 6502

    Joined:
    May 11, 2007
    Location:
    Oshkosh, WI
    #12
  13. Joined:
    Jun 30, 2009
  14. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #14
    If you don't want to use PHP for whatever reason you can also take a look at SSI (Server Side Includes) as long as your web host supports it (most do).

    Other resource on SSI from Wikipedia.

    I also support the idea of getting MAMP installed so you can test things locally more efficiently. SSI will need a server to be processed just like PHP.
     

Share This Page