Archive for the ‘PHP’ Category

Contact Us Through our New Contact Form on perceptus.ca

Sunday, January 9th, 2011

We did a largish update to our corporate homepage, perceptus.ca.

There are little changes here and there such as a new background graphic, some updates to the copy, and some changes to the layout.

The most important bit, which really was the catalyst for the change, was our  new contact form, complete with reCAPTCHA to keep the spam to a minimum.  The contact form is actually a test page for us, it’s designed to be highly portable, and you’ll see it on most of our critical websites very soon.

We might even publish the class file – it is far  better than the top few  contact form scripts in PHP that turn up on a search on Google.

PHP PEAR HTML_Template_IT Eats Dollar Signs

Wednesday, December 29th, 2010

Sigh.  We discovered a bug in our recently reworked tools.perceptus.ca (“PWT”) site.

We have a simple, custom, partial MVC system that runs a few of our smaller websites.  That system uses the PEAR HTML_Template_IT package to do the final template rendering. We ported PWT to our MVC to make future site changes much easier.

A week after going live with the changes, we found a baffling bug.  The tools were eating the dollar sign and dollar amounts (but not the decimals) from the input text. E.g. “$103.00” would get returned as “.00”.  Not good.

Apparently, HTML_Template_IT defaults to processing all text with regex.  Not cool.

There might be a historical reason for this, but for new users, this has got to be confusing. Plus, this is NOT mentioned in the intro documentation: http://pear.php.net/manual/en/package.html.html-template-it.intro.php

We’re not the only ones caught by this: http://pear.php.net/bugs/bug.php?id=50.

The fix is to initialize and set the use_preg option, like this:

$tpl = new HTML_Template_IT(‘./’,array(‘use_preg’=>true));

I have glanced at the package pages, and while this behavior is  documented it is buried quite deeply in the documentation.

This also explains a typo we had years ago on a static page that had the text like $5 in it.  That time, we just changed the copy to read 5 dollars and got on with life.