PHP classes for template

Hi folks,
I’m trying to build a simple template system that has basic SEO built into it. I know wordpress is good for putting simple sites together quickly and all that but I have a working version of this thing I’ve worked on already. The problem is, there is still quite a bit of manual tweaking I have to do for each site I build.

I would like to know how beneficial you think the use of classes is in the simplification of this template system. Stupid question I know…but keep in mind I said I’m building a very “simple” tool.

Also, I know there are a lot of systems out there, so in your opinion, is this just reinventing the wheel here?


Depends what you were trying to do I guess. i am still getting my head around when classes are being needed. The template I use looks like this. I declare a few variables, call an include, jump out of php, write content, include footer.

The variables are: text that is for <title>, text for breadcrumb, (optional) if i need to use css for just that page. The include has everything from the doctype to the opening div of my content part. Footer closes the main content div, copyright, ad, stats, </body></html>

Hey rguy84,
That’s the sort of setup I have already, but I was working on building a wordpress blog and got to looking a little deeper into their template. They have classes set up to do everything. So, everything is inherited when you create new instances of posts and all that. I dunno, maybe I don’t need anything that complex. Was just wondering what the real advantages were to designing that way.

Whenever mark-up elements are turned into objects it results in a more complex display layer. This is especially true for designers who don’t have a programming bone in their body. Making every HTML element some type of class is road best less traveled. However, taking common, repetitive display constructs such as; lists, trees and forms turning them into reusable helpers can be very useful. I use my own helper functions to build such elements and it reduces a significant amount of tedious, repetitive work, not to mention makes bug fixing and enhancement much less tedious. I just would advice choosing carefully what display constructs to automate presentation for. Its generally a good idea for things like forms, lists, trees, tables etc. All of which can have a common interface throughout an entire application and are reused throughout on a constant basis.

Thanks oddz, makes good sense. Hopefully I can turn the sense into dollars by saving time during development.