PDA

View Full Version : templating / dynamically create pages



ggalan
12-24-2009, 09:10 PM
can anyone point to a direction for me to learn how to make a template from multiple html pages?

djr33
12-24-2009, 11:24 PM
You can use a CMS system to do this automatically.
Beyond that, you can do this yourself by using a number of strategies. You should get familiar with includes and basic operations in PHP like ifs and variables.
Basically you need to strip out all the content and place the design into a page with "blanks" (probably variables, or maybe includes) for content.
You can, if you'd like, also use a database for this.

There are so many ways to do this, it really does depend on the project. If you aren't sure where to start and you just want to learn the methods, then just start anywhere and see what works best. If you have a specific project and goal in mind, post about that and we can point you in a more specific direction.

Also, I expect there are many "php templating tutorials" on google :)

And a last bit of general advice: when trying to do dynamic content like this, you need to make it as organized as possible, or there will be many problems with getting it to run smoothly and just for writing the code (even if it ends up working). For example, use CSS as much as possible and make sure all of your tabs line up correctly. This may seem obvious or unimportant, but it really will matter once you are trying to dynamically generate html-- the less mess you start with, the less you'll end up with. If you want to end up with clean html output (once generated, by "view->source"), then that may be the hardest part of this.