29

May

Kosh Lives!

Topic: TV, Movies, and Music
Tags:

One of the few pages left on my site that I hadn’t incorporated into WordPress (until now) was Ask Kosh. It dates back to about 1997 and is one of just a few pages that remains from my original site. It used to be its own self contained mini-site, with half a dozen pages of ancillary nonsense attached to it. I’ve stripped it down to just a single page, which I think will be enough to satisfy whatever interest remains in cryptic ol’ Kosh. Ask Kosh was a big hit back when Babylon 5 was still running new episodes - it even made a top 10 list in Total TV magazine.

27

May

Memorial Day Weekend

Topic: Kai and Eidan
Tags: , ,

Eidan sprays Kai with water on the first hot day of SpringEidan sprays Kai with water on the first hot day of Spring
Eidan sprays Kai with water on the first hot day of Spring

Today was the first hot day of the year, so the boys went at each other with spray bottles in the back yard. And it wasn’t long before they turned their sights on the cameraman (me).

On Sunday we took a trip to Franklin Square so the boys could enjoy some miniature golf. An unexpected sight while we were there was a freshly completed sand sculpture, celebrating Philadelphia. It was no Fukiage Beach Sand Festival, but it was fun to see, and reminded me of our time in Japan last year. Then we ended the day with dinner at Pho 75 in Chinatown. It all made for a very pleasant day.

Kai on the mini-golf course at Franklin Square Park
Kai on the mini-golf course at Franklin Square Park
A sand sculpture at Franklin Square Park
A sand sculpture at Franklin Square Park
Kai and Eidan getting the cameraman (me) wet
Kai and Eidan getting the cameraman (me) wet

15

May

Deko Boko - A reCAPTCHA Contact Form for WordPress

Topic: WordPress and Web Programming
Tags: ,

I now have available for download my second WordPress plugin: Deko Boko, a contact form that uses reCAPTCHA for spam protection. There are a number of good contact forms for WordPress, so why create another one? There are two things that make Deko Boko different from the others:

  1. It uses reCAPTCHA for blocking spam. reCAPTCHA is a great project that uses data from its captcha form submissions to help digitize books.
  2. The Deko Boko contact form can be extended any way you want, but without the need for complicated admin menus. If you’re comfortable editing HTML, then you can add any number and any type of input fields to the contact form. You can control which fields are optional or required. When the form is submitted, any fields that you added will have their data included in the body of the email.

The form layout is controlled by a CSS styled definition list, which provides a great deal of flexibility. With just a few CSS edits you can change the position of the field labels to top-aligned, left-justified, or right-justified.

Spam protection in addition to reCAPTCHA is also included. Deko Boko protects against email header injections and will verify that the return address provided by the user has a valid format.

This is a beta release (v0.8). I’ve been using it on my own site for some time and it’s working well. I’d like to hear feedback before making it an “official” release.

Go to the Deko Boko page for more information and to download it. Note that comments are turned off on the page - please submit any comments on this post.

12

May

Give Me A Race Car and an Earlobe, and There is Nothing I Cannot Do

Topic: Kai and Eidan
Tags:

Eidan's preschool picture, April 2008 (2 years old)Eidan’s preschool picture, April 2008 (2 years old)
Eidan’s preschool picture, April 2008 (2 years old)

Eidan got his report card for pre-school the other day. One of his teacher’s written comments was: “Eidan continues to be a joy in our classroom. His strong willed demeanor made potty training easy, but it also makes it difficult for him to be cooperative when given commands he doesn’t agree with.”

Yup, that’s our boy.

He was slow to start talking at first, but now he’s a chatterbox. We can’t always understand him, but that will come with time. My current favorite expression of his is “you scare me,” which he’ll say with a big smile anytime you show up unexpectedly.

Most kids get attached to a stuffed animal or a blanket, but not Eidan. He’s very attached to his Lightning McQueen and Chick Hicks toy cars right now (from the movie Cars - he calls them “kachow” and “chicka chicka,” since those are their catch phrases). He carries them everywhere, and even sleeps with them. He was also very attached to Maria’s earlobes for a while, rubbing them as a way of comforting himself. She finally made him stop when it got the point where he was rubbing her ears raw.

He also really enjoys going to Kai’s karate class. While Kai’s doing his class, I’m with him on the side, helping him practice his own version of karate. The teacher is kind enough to let him borrow a helmet, a small padded practice sword, and a kicking pad. He has a great time flailing his little arms and legs wildly, pretending he is a karate master.

He loves books now. He doesn’t know how to read yet, but he’ll happily flip through the pages and look at the pictures. His current routine is to go to bed with a stack of books (this is after Maria and I have already read to him) and look through them by himself until he’s ready to sleep. He’ll usually sneak out of bed at some point too, and bring some toys in bed with him. Tonight it was a toy hammer and goggles. He’s asleep now, with the goggles still on, a race car in his hand, a stack of books on one side of him, and a big toy fire engine on the other. I’ll go in soon to take most of it away, so it doesn’t all crash to the floor during the night.

5

May

Customizing WordPress: Limiting Categories on Your Home Page and Sidebar

Topic: WordPress and Web Programming
Tags:

If you click around into different parts of my site, you’ll notice that only certain categories of posts appear on the home page, and there are two variations to my sidebar. What I’ve done is make a single blog look like two different blogs: one for my professional work, and one for my personal posts. I’ve achieved these effects without using plugins, and without registering multiple sidebars. The only downside to my approach is that it’s not a technique you can use to control which widgets appear on which pages (but it’s fine if you want your widgets on all your pages). I don’t use widgets so it’s not a downside for me ;-) .

To follow along, you’ll need to be comfortable with editing a couple of your theme’s files, and be comfortable with the basics of PHP.

Limiting the categories on your home page can be done by adding a few lines of code to the top of your theme’s index.php file.

<?php if (is_home()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=12,23,6&paged=$paged");
} ?>

For “cat=” on the 3rd line, list the numbers for the categories you want to appear on your home page (or you can put a minus sign in front of the category numbers to exclude specific categories). The WordPress documentation for query_posts says you can do this with simpler syntax, but you can’t. The documentation is wrong. If you follow the suggestion there, your “Newer Entries” and “Older Entries” links on your home page won’t work. They will just continually re-load the most recent posts. The code I’ve given here is explained nicely in this WordPress support forum post.

So with this code, my home page includes only the categories related to my professional work. For my personal blog, I needed a way to get posts from all the right categories to appear together on a page. The answer is simple: I created a single parent category that encompasses all the categories I use for my personal posts. So the page for that parent category serves as the “home page” for my personal blog.

I also wanted my sidebar to change depending on whether you are viewing the “professional” pages or the “personal” pages. Achieving this involves two steps. First, add the following code to the top of your sidebar.php file. The category and page numbers you see listed are the ones where I want the “professional” sidebar to appear, which I call $home_sidebar (so you should substitute category and page numbers appropriate for your site). Note the ability to pass an array to is_category is new with WordPress 2.5.

<?php
$home_sidebar = false;
if (is_category(array(12,23,6))
  || in_category('12') || in_category('23') || in_category('6')
  || is_page(array(345,440,496,501)) || is_home()) {
      $home_sidebar = true;
}
?>

The second step is to check the value of $home_sidebar whenever you want to vary what appears in the sidebar. For example, to vary the category links in your sidebar, use code similar to this (again, substituting your category numbers). You’ll want to explore the options for the wp_list_categories function to get the exact appearance you want:

<ul>
<?php if ($home_sidebar) {
    wp_list_categories('include=12,23,6&feed=RSS&order=desc&title_li=');
}

else {
    wp_list_categories('child_of=26&feed=RSS&title_li=');
} ?>
</ul>

Note my use of child_of. This is the number for the parent category I created for all of my personal posts. This is a very convenient way to get all of the child categories without having to list them individually.

I’ve used this approach to make my blog look like two blogs. But you could easily extend this approach to subdivide your blog into as many mini-blogs as you like.