Posted by & filed under Developer Blog.

I needed to add a checkbox to Drupal’s Contact Us form for a client of mine. The client requested that I add a way for those filling out the form to request a newsletter. I discovered it’s pretty easy to add a form field and get it added as part of the email that’s sent. You just need to hack into the module on your server (sorry, no GUI for this). Here’s what I did:

First, find the module file:

modules/contact/contact.module

If you prefer command line editing open up that file in your favorite editor. If you prefer the download/edit/upload approach via FTP that will work also. I assume if you have interest in this article, that you have some knowledge of either of those 2 methods. If not, I wonder how you set up Drupal in the first place.

Now that you are in edit mode, find a chunk of code that talks about not allowing anonymous users to send themselves a copy for spam reasons. Found that comment? Good, now just above it you are going to add your field. I found it easy to copy/paste an existing form element and edit it’s contents, but you can type it out if you like. Actually, feel free to copy/paste and edit my example below. Here’s what I ended up with:

 $form['newsletter'] = array('#type' => 'checkbox',
    '#title' => t('Sign me up for the Newsletter'),
  );

You may want to add a comment somewhere in there to remind yourself at a later date that this is no longer part of the original configuration.

That was easy, now I just need to tell it to add content to the email sent out so that when that box is checked, it actually does something! Next look for a chunk of comment code that looks like this:

// Compose the body:

below that you will find a couple lines that start with “$message[] =” which is where the body of the email’s message gets created. Just add another line that says something like the following:

 if ($form_values['newsletter'] == 1) {
    $message[] = "Yes, please send me a newsletter";
  } else {
    $message[] = "No, please do not send me a newsletter";
  }

Now crank open your form and test it out. Assuming you are the recipient of the email being generated, you will get a nice extra piece of text at the bottom of the email with this new content based on the user’s input.

Posted by & filed under Developer Blog.

Twitter allows you to see who users are following, but for whatever reason, doesn’t allow you to see who is following users. This is lame, and I’m not sure what the thought process is behind it. But there’s a neat little Google search hack I came up with today that you can use to see just who’s following any given user. I’m pretty sure that this won’t give you an exact count, but it’s close enough.

just plug the following into your friendly Google search engine:

*username* “with_friends” site:twitter.com

The results will not only give you a nice list of who’s following that person, but a link to each of their Twitter pages.

So, for example. To see a list of who’s following Barack Obama, you would use the following search:

BarackObama “with_friends” site:twitter.com

Posted by & filed under Developer Blog.

This blog you are reading is powered by Mephisto. I originally created this blog using my own code in PHP and was so tired of re-inventing the wheel that I went out and researched what I thought would be the best blogging software for my needs. I’m in love with Ruby on Rails, so one of my requirements was that it had to be using that technology. In my research I narrowed it down to Typo and Mephisto, but there wasn’t much activity over in the Typo camp and there were plenty of people blogging about their switch from Mephisto to Typo. So, I chose Mephisto thinking it was the better of the two.

I’ve since realized that Typo’s development activity has gone way up, and Mephisto’s has gone way down. I have been using Typo on another blog venture of mine and am in love with it. Actually, I’m loving it much more than Mephisto these days for several reasons, most of which pertain to user friendliness. I did run into an issue with trackback spam on Typo, which I’ve read as a big complaint about it. But trackbacks aren’t even an option on Mephisto, so what’s the big deal?

The point I’m trying to make here is this. If there’s anyone out there with experience migrating from Mephisto to Typo I’d like to hear from you. There’s plenty of google hits about going from Typo to Mephisto, but nothing in the opposite direction. I’m interested in converting this blog, Tongue and Groove (once again).

Posted by & filed under Developer Blog.

For anyone out there using Adobe AIR products already: BEWARE!

Something that I didn’t pay much attention to when downloading Beta 1 was that it was going to stop working on December 11. I’ve been using an application called Ora Time and Expense that only works with Beta 1, which is why I haven’t switched to Beta 2 yet. But today that app stopped working.

I was using Ora Time and Expense to track my time for a project I’m working on. Actually, I finished on Saturday and was going to look at my time tracked tonight to create an invoice for the client. Wouldn’t you know it? Adobe AIR Beta 1 stopped working, and therefore I couldn’t access the time I had tracked. Ora’s website gives no help as they acknowledge that it only works with Beta 1 and for months now has promised a new version.

I finally had to get a Firefox extension that allowed me to view SQLite databases and search my hard drive for the te.db file where all of my data was stored. What a pain!

Just remember, Beta 2 stops working on June 1, 2008. If you find the next killer AIR app, make sure it’s not something you’ll need past that date.

Posted by & filed under Developer Blog.

You’ve seen piped navigation before. Typically found in the footer of websites, appearing as a list of links separated by a | (pipe).

There’s a nice way to fake piping using really clean, standards friendly code along with our friend, CSS. I’ve been using this method for years now and am quite happy with it. Basically, you start by creating a typical unordered list containing the list of links.

<ul id="piped">
  <li><a href="first">One</a></li>
  <li><a href="second">Two</a></li>
  <li class="last"><a href="third">Three</a></li>
</ul>

I’ll explain the class=”last” in a minute.

Now in your stylesheet you tell the list to be displayed without any bullets and displayed inline rather than stacked as is the default. You also give each link a nice pad on both the left and right. To fake the pipe, you simply add a border to one side. This is where the class=”last” comes in. You don’t want there to be a border after the last link, so for that class, you can simply set the border to none.

ul#piped li{
  display: inline;
  border-right: 1px solid #000;
  padding-left: 10px;
  padding-right: 7px;
}
ul#piped li.last{
  border-right: none;
}

(Realistically, you could also do border-left and class=”first.”)