The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

XML_HTMLSax (inspired by PHP Anthology II)

I don't know a lot about xml or dom, but I know that I've been looking for a better way to template and my ideas really seem to sync with what I've read about DOM. I just don't want to rely on the extention.

I have the PHP Anthology books, and XML_HTMLSax looked like a good way. Although I must admit, I tried experimenting with it and had no luck. I'm wondering if HarryF or someone else that has messed with XML_HTMLSax could show me how exactly to set up a simple tag based template system with XML_HTMLSax.

Thanks for the links.. I've been looking at phpoot tonight and looks interesting. I've looked at WACT a little and couldn't find any reference to XML_HTMLSax in the code. Thanks for the links and info!

Heh, I only found it because the alpha version of WACT didn't have the PEAR_LIBRARY_PATH constant set. So when I uploaded my application it didn't work yet threw no error. So I had to spend about 15 minutes doing a painstaking manual backtrace to track down the problem source.

Turned out it wasn't locating the required libraries, but becuase the include_once call had error suppression turned on it didn't throw a file not found error.

It's buried deep in there. Don't recommend WACT as a starting point though - perhaps something to explore once you've got further - there's now alot of abstractions around the template parser and the DelegatingSaxHandler is a basis for allowing Sax filters in WACT (which get's even more wierd if you haven't run into them before, I guess)

OK, sorry for all of the code, but this is my first attempt at making this happen. I just copied the code from the HTMLtoXHTMLHandler class. It's very basic, but it does what I planned. The template engine that I use (I guess it's not really a template engine, but rather a template variable storage class) in this example is very basic. The regular version checks to see if the tag is registered as an object, if so, it checks if the object has a method named $current_tag . '_tag'. So if the current tag was called 'title', it would check if the 'title' tag has been set, and if it is an object, check if it has the method called title_tag() and calls that.