Page 1 of 1

Dynamically Create Static Page

Posted: Sat Aug 02, 2008 10:22 pm
by Chalks
I have no idea if that subject makes any sense or not.


I've built a system that allows a user to create a full fledged menu for a website without using any html/css/whathaveyou. Currently, the menu requires a decent sized script with several mysql queries and one recursive function to display it properly on the frontend. I would really like to get rid of that script. I think the easiest way to do this is to make it so that whenever a new page is created on the backend, a file, "menus.php", is edited to reflect that new page. Then, instead of having a dynamic script on the frontend, I can simply include menus.php.

I'm not really sure what functions I should be looking into to do this. Pointers?
Will I run into cache issues if menus.php changes fairly regularly?


Thanks.

Re: Dynamically Create Static Page

Posted: Sun Aug 03, 2008 10:07 am
by pkbruker
You could save the output of the script in a file, then include that output in the final static file.

To save the output of your script, look into fopen(), fwrite() and fclose().

Then, to include the menu in your staic page, do something like this:

Code: Select all

 
 
// Output the part of the HTML page that is before the menu
 
// Output the menu
include "menu.html";
 
// Output the part of the HTML page that is after the menu
 
 
To change the menu, simply run your script one more time and overwrite the current menu HTML file. This will cause the "static" page to automatically update.