Forum Moderators: coopster
I can't think of any downside other than a single page that's somewhat complex.
Comments?
In a db driven site, if the format of the page is identical - where the only thing that changes is the db inserted content - then one page is the way to go. One page of code to manage regardless of the number of content pages it produces.
But if you have content imbedded in the code, like:
if ($page == '') { echo "blah blah"; } elseif ($page == 'about') { echo 'bleh bleh bleh'; } etc...
...then separate pages are easier to manage in my experience. When I'm editing pages I like to look at as little of the surrounding HTML/PHP as possible.
"yes - it's index dot p-h-p, then a Question mark, pg, equals sign... "
Aside from that kind of argument, there's no reason not to do what you describe. A lot can be done with htaccess mapping and redirects.
There are common sense limits. If your page looks like:
if ($HTTP_GET_VARS['pg']=='contactme'){
// 6 pages of HTML
} elseif ($HTTP_GET_VARS['pg']=='mystuff'){
// 6 more pages of HTML
} elseif ($HTTP_GET_VARS['pg']=='things'){
// 10 pages of HTML
} elseif ($HTTP_GET_VARS['pg']=='work'){
...
then parsing your code might get a little slow. Though the disadvantages are negligible, I don't see any advantages, either.
These forums do something similar.
webmasterworld.com/forum88/3741.htm
/forum88/ is php related
/fourm89/ is ad sense
point is that it's all coming from 1 page probably named forum.php or what have you. Bretts just re writing the string from something like this forum.php?cat=88 to forum88/
so one page is now 1000's of different pages.
You might want to use real sensible URLs with real names, so people can bookmark them and write them on cocktail napkins, and when you want to direct someone by phone you're not explaining all about the question mark thing.
Yeah, I've been thinking about this, too. What I need to learn next is how to make my links look like easy-to-read subcategories (e.g., widgets.com/redwidgets/smallredwidgets/ instead of widgets.com?c1=redwidgets&c2=smallredwidgets) without actually having those subdirectories and with the URL in the browser look like /redwidgets/smallredwidgets/.
It's about 3 lines of code in your .htaccess file that's it.
I know it seems natural (need another page, just have it generate another page) but the actual fact was that at times I wanted to generate a page right off the bat for a specific purpose, but ended up generalizing it to fit it into the template, finding where the general dynamic template didn't really scale well, fixing that, etc....
All statics is clearly not ideal, but I think all dynamic is also non-ideal.
A curent site under development uses my own version of a templating system, where the main page generates subpages, which then generate the content on the fly. This way I have a handful of coded pages which generate the hundreds of pages making up the site. The handful is varied enough to handle all of my needs, and if necessary I easily make one more following the same design.
Basically I abstracted with a layer between content and index.html, and so far it works very well. Nice set of include files, and very little redundant code. I am consciously avoiding further automating those (even though it seems so cool to do that) because I don't need to....
- use mod_rewrite to send everything to index.php.
- check the url. Is this a valid address for a file? If so, just show that file
- if not, generate the dynamic page with the default template.
Solution two
- each dynamic page has information (either in the db or as a file header or whatever) that says which template to use and have 2-3 templates.
This requires knowledge of valid file names, which means you need a table of all valid files.
That was the solution I ended up with, but I used a custom4040 handler to do the page generation when the file was supposed to be there but wasn't. Clear the directory to auto re-generate the files at next request. Works like a charm, but I feel lucky I'm not doing much maintenance on that site.