Imx Fix in my experience
 
« prev next »

February 20, 2003 9:34 AM


Morbus Iff was curious about "the faces you used for your commenting." He asked "How do you have that hooked into Movable Type? What's storing the 'what face you chose' info?" I answered via email, but it's probably useful to post this up on the site...

First, I don't write anything into any db tables or handle any hidden form elements, instead I'm using two plugins from Brad Choate (this one and that one). One of them lets me read any MovableType field and see if there is a key value pair in that field. I'm placing a key and value into the MTCommentBody field when a user submits a comment in this format...

faceurl=some/url/to/an/image.gif

...and goes at the end of the comment (placed there via JavaScript). At the same time, I set that value into a cookie. Currently, I am only saving that value if they select one of the faces I have in the pop up menu. If you select the 'normal guy' I don't save it's value (and assume a default later...)

In the individual archive template, I use the key-value plugin to look into the MTCommentBody fields to see if faceurl exists, and if so, we use its value to set the src of the face icon image. If there is none at all, I assume the default and insert the url for 'Normal Guy.'

THEN, when we output the value of the comment body, we regex MTCommentBody to remove any face url text...

s/faceurl\=[\w|\W|\S]*//g

Don't laugh an my lame regex skills. heheheh.

Future plans are to make it possible to save any URL to an image the user wants. Currently, if you select 'normal guy' as the face, and then write in "faceurl="http://yoursite.com/your_image.gif" on the bottom line of your comment, that url will be used. But it isn't currently saved.

Rumors are that the Pro version of MovableType will have custom form fields making all of the above unnecessary (except for the cookie thing).