Web Hosting Talk







View Full Version : Tough HTML question...experts needed asap


HammerHost
04-01-2004, 09:27 PM
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

Dan L
04-01-2004, 09:58 PM
PHP!

Make your index.php page have your layout.. where the content goes:

<?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. :)

HammerHost
04-01-2004, 11:37 PM
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

Joe Bonanno
04-02-2004, 02:08 AM
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.

Website Rob
04-02-2004, 03:36 AM
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 (http://htmlhelp.com/cgi-bin/validate.cgi?url=http%3A%2F%2Fwww.muscle-mustangs.com%2F&warnings=yes), there is improper TABLE nesting and few other errors.

leight
04-02-2004, 09:54 AM
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.

Dan L
04-02-2004, 11:08 PM
xtremestang1, PM me if you want a step by step, don't want to type it up if you choose SSI or a CMS. :)

barnettgs
10-01-2005, 09:56 AM
Originally posted by DanX
PHP!

Make your index.php page have your layout.. where the content goes:

<?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

jimlundeen
10-01-2005, 10:06 AM
If your server allows Server-Side Includes, use them. Otherwise go the PHP route.

barnettgs
10-01-2005, 10:10 AM
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

jimlundeen
10-01-2005, 10:15 AM
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.

Dan L
10-02-2005, 06:19 PM
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 :)