Matt Waterworth

Biography

Matt Waterworth is an experienced web developer and second-rate Jack Osbourne impersonator. He specialises in devising and implementing PHP-based web applications. He is an advocate of practical pattern-based object-orientated design.

He is a part-time internet marketer, blogger and domainer who catalogues his entrepreneurial misadventures on TakeMoreRisks.com.

Contact Matt

Fake project idea

Frank In A Skirt.com

A pressure group who's ultimate aim is to coerce Frank Mitchell into wearing a skirt and a wonderbra during his live Weather Watchers spot.

We'll use all donations to pay Pamela Ballantine to force him to crossdress. Although I'm doubting she really needs paying.

I'm sure it's her fantasy to see Big Frank slinking about in a skirt like a big slag.

Week 11 Research

Design Research for Justin Nicholl Site

The State Of My Index Page

My index page is an absolute mess. I'm missing a genuine opportunity to showcase my technical skills here (or lack thereof). It's just I don't know what to put here.

I was originally thinking of redirecting the user to the current week's page but I think that's stupid. I could just place a link that says "Click here to view the current weeks content" anyway.

I need some better ideas!

A Tag Cloud 

Another option would be to build in something fancy like a tag cloud. I've a vague idea of how to go about this. Basically I'd have to write a script that went through each of my posts stored in the database, searching each entry for commonly occuring words. It wouldn't be necessary to dynamically regenerate the cloud each time someone visits the page. I could do it every time I update or create a post.

Now the thing is I just know that "FUCK" would probably appear as the largest keyword. This could be a bit of a problem if an employer came along. Unless that employer was Shane McGowan. Or Christopher Murphy.


This is Shane McGowan. In a cloud.

Obviously I could make fuck a stop word. Or I could just stop swearing in these posts. But y'know I won't. As it's nearly Christmas and all. I digress.

PEAR HTML_Tag_Cloud

Once I've found the most commonly occuring words I'll need to format them into a tag cloud. This is where PEAR comes to the rescue again with the HTML_Tag_Cloud package.

Unfortunately it only deals with handling the presentation of the cloud (I was hoping for a little more help with the backend!).

You seem to add elements to the cloud through a statement like this

$tags->addElement('PHP'       ,'http://www.php.net'  39strtotime('-1 day'));

From what I understand the first argument is the cloud node text, followed by the URL the text points to and then it's importance. I think I'll need to put this into a foreach loop which iterates over an array of the phrases I've indexed from all of my posts. I'm now convinced I could get something basic up and running. The only problem is, making it good and ultimately worthwhile to the end user.

How Do I Actually Edit The Index Page?

In case you aren't aware - CakePHP uses special class files called controllers to contain business logic (or random code as I prefer to call it). However, I don't understand how to control the content that appears on the index page. Ideally I should be able to create an index controller along with some appropriate templates to control it's appearance.

But no! Things are never that simple.

Ok, it seems as though you have to create a PagesController to take care of this. I found this out through the routes.php file which is responsible for handling custom mod_rewrite's and such. It would be easy enough to specify a different controller to use for the index page but I might as well stick to the conventions they've layed out. 

This Week Section Changed Into A Contact Form

I've been trying to get the Del.icio.us API driven 'This Week' links section to work properly for a couple of weeks now but to no avail. I guess it seemed as if it was a good idea at the time but now I realise I'd rather place links to sites inside the content, along with some pictures and a more in-depth description of the page.

I'm developing a 'Contact Matt' form that'll allow any potential employers (or anyone else for that matter) to contact me.  I'm unsure over how to go about this. There are several possible ways of implementing it. I think the best option may be to create a Contact controller and model and embed both inside the AppController. This will allow me to place the 'Contact Me' form on every page on the site.

The Short Story of Creating the Contact Form in CakePHP

Ok so after I created the contact controller and the contacts table in the database I set about marking up the form using the CakePHP HTML helper. At first I couldn't understand why anyone would use the HTML helper as you are actually typing about the same amount of code as if you were to use raw HTML. 

echo $html->input("Contact/name");

However the cool thing is, if you submit the form with errorenous data, the HTML helper will automatically fill in the value the user typed into the input box before submitting. This would require quite a bit more code. 

Another cool thing I learnt tonight is how if you add "created" or "modified" attributes to a database table then CakePHP will automatically update these columns for you once a record has been successfully submitted.  It just makes things that bit easier, especially if you hate converting dates between PHP and MySQL.

I realised that it would be necessary to add in some validation into the form to ensure the user has entered a valid email address along with a name and a message. Thankfully Cake has built-in validation techniques that you specify inside an array in the relevant model, which are then executed once a record's been submitted.

In my Contact model I included the following array

var $validate = array(
 
      'name' => VALID_NOT_EMPTY,
      'email' => VALID_EMAIL,
      'message' => VALID_NOT_EMPTY
   );

Now the email will only send if the user enters a name, message and valid email address. As it stands though there are no real error feedback messages. Well until now that is. To add in an error message for the name input box I included this bit of code

echo $html->tagErrorMsg('Contact/name', 'Please enter your name.');

The tagErrorMsg method in the HTML Helper automatically embeds the "Please enter your name" message inside a div with a class called "error_message". To make the errors more obvious I added this selector to my stylesheet.

.error_message {
color: #FF0000;
font-size: 1.2em;
}

 http://www.mattwaterworth.com/des511j1/img/errormess.jpg