| Thread Closed |
publishing dynamic pages to flat HTML |
Share Thread | Thread Tools |
| Feb11-07, 05:27 PM | #1 |
|
|
publishing dynamic pages to flat HTML
I want to be able to generate pages from a database but the data only changes occasionally. It'd be more efficient to have the pages served up from flat HTML most of the time and only have to "publish" to HTML when I make a change to the database.
Is there a really convenient way of doing this? PERL's the trick, isn't it? |
| Feb11-07, 05:40 PM | #2 |
|
|
Could you cache the data? Seems less hassle than writing files out.
|
| Feb11-07, 06:39 PM | #3 |
|
|
|
| Feb11-07, 09:09 PM | #4 |
|
Recognitions:
|
publishing dynamic pages to flat HTML
You can pretty much use any language you want to generate the html, anything at all. It doesn't have to run inside the web server, so you're not limited to server-side languages. Also since this will be run only so often, only locally, and only by you, performance isn't much of a factor either.
The only thing you have to consider is whether in the future you might find yourself having to update the content so often you have to go back to dynamically generated pages. |
| Feb11-07, 09:20 PM | #5 |
|
|
What I have: Currently, my portal is built in PHP/MySQL. Every time I access my portal, the PHP has to build it from scratch and deliver it to me. It takes 5-20 seconds or more. If I want to make a change, I have a web control panel right there on my page where I make edits and then save. What I want: I want to have my portal on a flat HTML page, so it loads fast. When I want to add a link, I go to my web control panel and make the change, which is saved to the db. This db save triggers some app that writes a new HTML page, so that my portal when I go to it now has the new content. The key here, is that my portal admin operations must all be web-based. I might not be at my home computer when I want to add a new link. I won't have any files, I won't have an ftp app, I won't have any editor (except the web-based one I've built). |
| Feb11-07, 09:31 PM | #6 |
|
Recognitions:
|
You can still use anything you want, because you can have a PHP script start your HTML writer app. Of course since you have PHP available i would just use PHP.
Your PHP script would look like a regular server-side script, the difference being that it writes the html out to a file, instead of to an output stream. |
| Feb12-07, 12:27 AM | #7 |
|
|
|
| Feb12-07, 07:58 AM | #8 |
|
|
Is there an efficient way of redirecting my PHP to a file rather than back to my browser? I've got all the code to make the page; I hope I don't have to rebuild it all as print statements...
|
| Feb12-07, 09:19 PM | #9 |
|
Recognitions:
|
|
| Feb12-07, 09:46 PM | #10 |
|
Recognitions:
|
Dave, what you could do is the following. Write out your website in PHP as if you meant to leave it as a dynamically generated site. Suppose you have the following structure:
Code:
/root file1.php file2.php Code:
/root file1.php file1.htm file2.php file2.htm Converting from php to html, just involves running the PHP and capturing the HTML it outputs. So suppose you do an http request from your local server to your local server for the file "http://localhost/root/file1.php". Then your server will reply with the html, and all you have to do is save it to a file. You can do http requests with PHP, using fopen: Code:
$handle = fopen("http://www.example.com/", "r");
Inside generator.php you get the value of the page variable: Code:
$targetPhpPage = $_GET["page"];
$targetHtmPage = str_ireplace(".php", ".htm", $targetPhpPage);
Code:
$handle = fopen("http://localhost/root/" . $targetPage, "r");
Code:
while ($data = fread($handle, 4096)) {
//dump $data to $targetHtmPage
}
This way if in the future you find that you don't need this process anymore, you won't need to change anything, just make your php pages directly available. For reference: http://us3.php.net/fopen http://us2.php.net/manual/en/function.str-ireplace.php http://us2.php.net/manual/en/function.fread.php |
| Feb18-07, 07:23 PM | #11 |
|
|
I will try this. Thanks muchly.
|
| Thread Closed |
| Thread Tools | |
Similar Threads for: publishing dynamic pages to flat HTML
|
||||
| Thread | Forum | Replies | ||
| Latex: odd pages = figures, even pages = text? | Math & Science Software | 0 | ||
| publishing dynamic pages to flat HTML | Programming & Comp Sci | 0 | ||
| Online Publishing | Academic Guidance | 0 | ||
| Publishing papers | Academic Guidance | 13 | ||
| Eliminate clutter in Microsoft Word generated HTML files with the Office 2000 HTML Filter | Computing & Technology | 0 | ||