Results 1 to 12 of 12
  1. #1

    Tough HTML question...experts needed asap

    I'm creating my Mustang website and I have a box for the background and I have text over it for latest news on the site. I put news in their everytime I update the site. I update daily almost.

    My question is, instead of going to all of the HTML page and retyping the text. After the site grows that would be hundreds of HTML pages to edit daily. I was wondering if their was some kind of a script that when I change one they all change.

    you can check out what I mean on my site: the box I want to do this to is the latest news box

    www.muscle-mustangs.com


    thanks to all

  2. #2
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    PHP!

    Make your index.php page have your layout.. where the content goes:
    Code:
    <?php
    $server = $_SERVER['QUERY_STRING'];
    $server = 'content/'.$server.'.dat';
    $server = file_exists($server) ? $server : 'content/index.dat';
    if(file_exists($server))
    {
    include $server;
    }
    else
    {
    die('Critical Error.');
    }
    ?>
    Now, make each content page look like 'page.dat' and put it in content/. Now, make all your links look like: <a href="?page">Page</a>

    You're good to go!

    If anything didn't make sense, I'd be glad to elaborate on it.

  3. #3
    hmm....I don't understand, could you maybe lend me a hand?

    I don't have an index.php. I only have a index.html

    If you could show me step by step what to do that would be great

  4. #4
    Join Date
    Apr 2003
    Posts
    369
    A simple alternative would be to use Server Side Includes (SSI). It is very simple. The notation looks just like comments in HTML.

    <!--#include file="todaysnews.txt"-->

    The above goes in place of any text and html presentation markup. The included file is just a text file that may or may not include any additional html as necessary.

    You can also include cgi scripts for light duty work.

    I like SSI because the I don't feel the need to use mod_rewrite or string parsing to eliminate the .php or .pl file extentions.

  5. #5
    Join Date
    Sep 2000
    Location
    Alberta, Canada
    Posts
    3,109
    I would also suggest using SSI, but would do it this way.

    Create a dir for only SSI pages, include the whole TABLE code in the SSI page then reference whatever page you want.

    i.e.
    in your public_html dir. you have a dir. called 'ssi_txt' and page called 'article1.txt' which contains the whole HTML for that article. Then, in your HTML page you reference it by using:

    <!--#include virtual="/ssi_txt/article1.txt" -->

    That will display your HTML code as if it was coded directly in the index.html.

    If you want to continue using the 'html' extension but also use SSI, then you need to add this code in your .htaccess file:

    AddHandler server-parsed html


    I would also fix up your HTML code, there is improper TABLE nesting and few other errors.
    PotentProducts.com - for all your Hosting needs
    Helping people Host, Create and Maintain their Web Site
    ServerAdmin Services also available

  6. #6
    Join Date
    Apr 2004
    Location
    East Anglia, UK
    Posts
    79
    An alternative solution would be to look into getting a Content Management System (or CMS), which makes it a hell of a lot easier for you to add/delete/edit content, but will also update all of the pages affected by the content changes automatically.

    There are plenty of free CMS' out there. The deal is for a little bit of extra time setting up your site, you get far better managability in the future.

  7. #7
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    xtremestang1, PM me if you want a step by step, don't want to type it up if you choose SSI or a CMS.

  8. #8
    Originally posted by DanX
    PHP!

    Make your index.php page have your layout.. where the content goes:
    Code:
    <?php
    $server = $_SERVER['QUERY_STRING'];
    $server = 'content/'.$server.'.dat';
    $server = file_exists($server) ? $server : 'content/index.dat';
    if(file_exists($server))
    {
    include $server;
    }
    else
    {
    die('Critical Error.');
    }
    ?>
    Now, make each content page look like 'page.dat' and put it in content/. Now, make all your links look like: <a href="?page">Page</a>

    You're good to go!

    If anything didn't make sense, I'd be glad to elaborate on it.
    Hi, I'm new here and I've been searching for ages for this code! I'm happy to have found your code just what I wanted but there is one question I would like to ask:

    Apart from index.php, is it ok to use .html extension in content directory instead of .dat?

    Because I find it easier to edit & add html page in my html editor.

    Thanks
    Last edited by barnettgs; 10-01-2005 at 10:03 AM.

  9. #9
    Join Date
    Sep 2005
    Location
    Cleveland, Ohio
    Posts
    51
    If your server allows Server-Side Includes, use them. Otherwise go the PHP route.

  10. #10
    Originally posted by jimlundeen
    If your server allows Server-Side Includes, use them. Otherwise go the PHP route.
    Yeah, my server allows SSI so does that means I can use any extensions?

    I noticed some SSI tutorials use inludes files with .inc or .txt extension but does it really matters?

    Cheers

  11. #11
    Join Date
    Sep 2005
    Location
    Cleveland, Ohio
    Posts
    51
    for the files that are being included, you can use whatever you like. I prefer ".inc" but it doesn't matter. for the page that has the include command, it usually must have "shtml" or "shtm" extention -- ask your administrator for advice.

  12. #12
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    I haven't seen any benefits of using SSI.

    My code will work fine with .html, just change lines three and four to reflect it.

    Talk about an old 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
  •