2 replies [Last post]
Last seen: 18 years 31 weeks ago
Joined: 2004-01-12
Posts: 1
Points: 0

Okay, I'm fairly new at PHP though not so with CSS, and I've thought long and hard about this, but I can't seem to figure it out...

What I'm trying to do is create a page for a site that contains a list of written works... Seeing as the layout for the site changes frequently, it's a gigantic amount of work to go back and alter every single HTML file to coincide with the layout used.

So what I was thinking of was using the piece of code:

<?php require("somefile.htm"); ?>

to call up the required text, and to have the format converted to what's specified in the PHP file... However, this specific instance only calls up the file specified... Basically, I'm trying to do it in a reverse order... To have a list of links to the pieces of writing, and clicking on any one will produce the desired work in the format specified in said PHP file... Which in turn would reduce altering the layout to changing a single file...

In other words...

For instance, say I have the link:

001: Story Pt.1 (storypt1.htm)

Which contains nothing more than:

This is the story...

Normally, you could just handle a single file by having the link point a PHP file like:

(This is the CSS)
<?php require("storypt1.htm"); ?>

Where the 'PHP require' code would take storypt1.htm and modify it to fit the CSS... Granted, it does work, but if I did it that way, I would still have to change an unreasonable amount of files when changing layouts, due to the code only specifying "storypt1.htm".

So, what I'm looking for is some general piece of PHP that will allow one to choose from any number of links of plain HTML files, and have the code 'export' the data in the style specified in the CSS of the PHP file. This way, to change all the pieces of writing, I would only have to alter the page with this general PHP code...

Does that make sense? I heard somewhere that you could perform this entirely by CSS, but I'm not sure about that...

Could someone please clear this up for me?

Thanks in advance!

dJomp's picture
Last seen: 6 years 28 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

CSS/HTML/PHP question...

(moved 'cos really it's a PHP question)

The easiest way to do it?

It would involve a bit of work initially, but it would get easier.

First strip all the HTML tags out of the story html files (bar maybe P and BR) so essentially it's just the story. No reason why this can't be automated, so you don't actually have to hand-edit each file...

Then you have a PHP file similar to the one in your post, with headers etc, and include the 'text' of the story in one place.

If you don't want to / can't edit the story HTML files; rather than including them, read them into PHP and run some preg_replace()s to remove the unwanted HTML.

I'm not sure if I'm on the correct lines though. Do you have an example of the story you're trying to read in?

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

Sydney, Australia
Last seen: 18 years 39 weeks ago
Sydney, Australia
Timezone: GMT+10
Joined: 2003-11-15
Posts: 389
Points: 0

CSS/HTML/PHP question...

Maybe we should have a PHP heading - there seems to be enough questions.


The only way to learn is to do it yourself