[thelist] How to implement static page generator?

Mark Howells mark at mountain.ch
Fri Mar 8 07:12:01 CST 2002


> I'm planning on writing my own blog script in php

[snip]

> If I change, for instance, my menu structure so it has one
> extra link in it, how will I be able to get my program to
> regenerate all the static files? (entry info will be stored
> in a db, btw).

Two options:

a) You could add a specific feature that would "republish" all of the files
when you asked for it, like the Greymatter and Blogger features.

b) Use Server Side Includes to include the menu section of the pages--in
this case, you'd be using PHP to write PHP code into the stored pages which
is complex, but not impossible. You don't need to use PHP to do this--most
regular HTML servers allow it--but I'd recommend it for the sake of
simplicity in maintaining your code base.

> Also - after I do the blog, I'm planning on
> having other parts of the site which I'll want to do the
> same thing with. The trouble is, since they'll be quite
> different, they'll use different scripts to generate the
> pages. How could I implement some way of doing the first
> one, so that when I want to make a change to the template
> structure I can have it automatically regenerate all the
> pages?

Again, the easiest way to do this would be to have a "republish" button in
your editing system. And develop common PHP functions which accept
parameters, so that you can reuse them.

E.g.

function republish($targetFolder,$dbTableName,$dateRange){
 // your code here
}

> P.S. (I know systems are already round for blogging and
> this type of thing. I want to reinvent the wheel for the
> purpose of teaching myself, so please no replies telling me
> I should be using xyz blog software).

Ok, I won't mention <http://www.cafelog.com/> then ... oops. You don't have
to use it, but the code might give you some ideas and help in building your
system. That, and closely analysing the functionality of existing systems
will help with logic flow, application and session design.

Regards
Mark Howells
<http://www.mark.ac/evl/>




More information about the thelist mailing list