SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Update Identicle Part of Multiple Sites From 1 File?

    I'm going to be displaying some information + links on multipe different sites and ill be changing the information/links sometimes.. Instead of having to update every single site is there a way I can have all the websites get the information from 1 single file? so when the file is changes it changes the information on all the websites at once?

  2. #2
    Resident curmudgeon bronze trophy gary.turner's Avatar
    Join Date
    Jan 2009
    Location
    Dallas
    Posts
    990
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please research server side includes. The Apache web server, among others, supports pre-processing instructions. See the Apache manual.

    Alternatively, use the include function that most, if not all, server languages support. See your language manual.

    cheers,

    gary
    Anyone can build a usable website. It takes a graphic
    designer to make it slow, confusing, and painful to use.

    Simple minded html & css demos and tutorials

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    would the sites have to be on the same server since u suggested server side includes?

  4. #4
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    which server side programming language you are using to create website.

    vineet

  5. #5
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    If you use something like PHP includes, yes you can insert the file from your different servers/sites and they should update automatically assuming your servers are correctly set-up and allow it, etc.

  6. #6
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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" />
    This is a rough example of PHP server side includes. Say that above code will be EVERYWHERE in the site. Let's call that header.php
    On your other page..lets call it blog.php, just add this at the top of the file, and it will sorta like cut and paste the header.php content directly into blog.php (not really, but it's similar)

    Code:
    <!--blog.php-->
    <?php include("header.php"); ?>
    <!--rest of page blah blah-->
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  7. #7
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,881
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by enwise View Post
    I'm going to be displaying some information + links on multipe different sites and ill be changing the information/links sometimes.. Instead of having to update every single site is there a way I can have all the websites get the information from 1 single file? so when the file is changes it changes the information on all the websites at once?
    One way to include an HTML fragment is with "server-side includes". However, this only works within one server - ie, you would need a separate setup on each server you are using.

    To do this, you need to rename all your files to .shtml instead of .htm or .html - you can then use the code <!--#include virtual="/file.htm" -->, where "file.htm" is the fragment to be included in each page. You can either set a root reference, as here, or a relative reference, eg "../dynamic/file.htm".

  8. #8
    Resident curmudgeon bronze trophy gary.turner's Avatar
    Join Date
    Jan 2009
    Location
    Dallas
    Posts
    990
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stevie D View Post
    One way to include an HTML fragment is with "server-side includes". However, this only works within one server - ie, you would need a separate setup on each server you are using.
    Server configuration ios a separate issue. The include syntax is standardized since the first server, NCSA HTTPd.

    To do this, you need to rename all your files to .shtml instead of .htm or .html - you can then use the code <!--#include virtual="/file.htm" -->, where "file.htm" is the fragment to be included in each page. You can either set a root reference, as here, or a relative reference, eg "../dynamic/file.htm".
    Not necessarily; In Apache, at least, you can set the xBitHack on. If you do, you may keep the "normal" extensions, and simply set the x bit on the file using chmod +x <filename>.

    cheers,

    gary
    Anyone can build a usable website. It takes a graphic
    designer to make it slow, confusing, and painful to use.

    Simple minded html & css demos and tutorials

  9. #9
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,881
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by gary.turner View Post
    Server configuration ios a separate issue. The include syntax is standardized since the first server, NCSA HTTPd.
    Sorry, what I meant was that on pages on website1.com could include "website1.com/fragment.htm", but if you needed to include the same code on pages on website2.com, you would need to set up "website2.com/fragment.htm" - you can't include fragments from another server.

    Hmmm, that last seven words summed it up perfectly. Why did I make such a hash of explaining it earlier?

    Not necessarily; In Apache, at least, you can set the xBitHack on. If you do, you may keep the "normal" extensions, and simply set the x bit on the file using chmod +x <filename>.
    Well you learn something new every day! If I'd known that 3 years ago, I wouldn't have had to mess around with mod_rewrite to map all my .htm files into .shtml ones...

  10. #10
    Resident curmudgeon bronze trophy gary.turner's Avatar
    Join Date
    Jan 2009
    Location
    Dallas
    Posts
    990
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For the details of SSI, and using the XBitHck, see http://httpd.apache.org/docs/2.2/howto/ssi.html.

    cheers,

    gary
    Anyone can build a usable website. It takes a graphic
    designer to make it slow, confusing, and painful to use.

    Simple minded html & css demos and tutorials


Bookmarks

Posting Permissions

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