Elsewhere: So You’ve Got a Drupal Website… Now What? (Part Two: Learning the Lingo)
I just posted So You’ve Got a Drupal Website… Now What? (Part Two: Learning the Lingo) on ClickOptimize.com:
In this series, I walk you through the basics of using your shiny new Drupal website. In part one, I explained what Drupal is and why it’s awesome. We’ll get into working with Drupal in the next section. Before we can walk the Drupal walk, however, we need to learn to talk the Drupal talk.
Read the whole article on ClickOptimize.com.
Elsewhere: So You’ve Got a Drupal Website… Now What? (Part One: What is Drupal)
I just posted So You’ve Got a Drupal Website… Now What? (Part One: What is Drupal) on ClickOptimize.com.
It’s shiny. It’s new. And it’s totally mind-boggling how much you can do with it. The only trouble is, you have no idea where to start. In this series, I’ll walk you through all the useful bits and bobs in your new Drupal site, how to use them, and all of the situationally useful extra stuff you can safely ignore 99% of the time.
Read the whole article on ClickOptimize.com.
Attach Files to Taxonomy Terms in Drupal
From what I can tell, there are plenty of ways to attach files to nodes in Drupal, and even a few ways to attach them to users, but none that I could find to attach them to taxonomy terms (images through the Taxonomy Image module, for sure, but not files in general). My guess is that there just aren’t enough people who need to do so.
In a recent project, however, I found myself needing just that. The client in question was using a vocabulary of fonts that had to be associated with their respective font files for JavaScript. After beating my head against the problem for awhile, I managed to figure out a solution. Instead of attaching a file directly to the taxonomy term, I assigned the same vocabulary to a new content type to hold the attachment. Here’s how it works:
- Go to Administer > Site building > Modules and make sure the core Taxonomy and Upload modules are enabled.
- Go to Administer > Content management > Content types and click the link at the bottom to Add a new content type.
- Give your new content type an intuitive name (e.g., Font File) and enable attachments under Workflow settings. Configure the other settings as you see fit and hit Save.
- Go to Administer > Content management > Taxonomy and edit the vocabulary for which the file attachments are intended (e.g., Fonts). Check the box next to your new content type and click Save.
Great! Now you have a way of associating a term with a file, albeit indirectly through a node. How you use that information will, of course, vary. In my case, the font files needed to be populated into a drop-down list of font choices for use by JavaScript. Here’s how you might go about accessing the attachment from the database:
<?php
// Fetch the file path of the most recently uploaded file attached to a node that shares the given term
$attachment_path = db_result(db_query("
SELECT filepath FROM {files} f JOIN {upload} u ON f.fid = u.fid JOIN {node} n ON u.vid = n.vid JOIN {term_node} tn ON n.vid = tn.vid WHERE n.type = '%s' AND tn.tid = %d ORDER BY f.timestamp DESC LIMIT 1
", $NODE_TYPE_NAME, $TERM_ID));
?>
Of course, the best solution would be to create a custom module to handle all of this. In my case, there simply wasn’t enough time for that. I invite some enterprising developer to invalidate my technique by creating a module that allows file attachments on taxonomy terms. Until then, I hope someone finds my roundabout hack useful.
7 Signals of Comment Spam
Recently, I’ve found myself giving the same advice to several of my clients, many of whom are still getting into the swing of blogging. All too often, they’re uncertain about whether or not to mark a comment as spam. Caught between the desire to avoid spam but foster legitimate conversation, they come to me, and these are the seven signals I tell them to look out for:
- Links to Spammy Sites. The biggest red flag should always be links provided by the commenter. Visit them and you can usually figure out pretty quickly if the commenter is working an angle. I’ve marked well-thought-out, on-topic comments as spam before because they linked to sites I didn’t care to be associated with.
- Lots of Links. There are very few situations I’ve ever seen in which a comment with more than two or three links isn’t spam. If the comment is chock full of them, or, worse, is nothing but a list of links, you should hear alarm bells ringing.
- Overuse of Keywords. Perhaps one of the most obvious cues is when a comment seems like little more than a list of keywords. This may be blatant, or the keywords may be hidden within the comment, at the end of the comment, or in the commenter’s name. This sort of spam is easy to catch, but you have to be willing to give your comments more than a cursory glance.
- Off-topic. While not a clear signal in and of itself, the topic of a comment can nevertheless be an important clue. Ask yourself what the commenter is talking about. Does it flow from the article in a natural way, or is it marginally related at best? Does it unambiguously mention anything from the article? The more it strays from the topic at hand, the more likely it’s copied-and-pasted junk.
- Complimentary. Make no mistake; spammers will play to your ego if they think it will get their comments posted. Beware comments that pay too much respect to your work. They may just be buttering you up to compromise your better judgment.
- Irregular Size. Comments vary in length, but extremely short or long comments beg greater scrutiny.
- Poor Grammar. This isn’t to say that ordinary commenters don’t have atrocious grammar some of the time. However, it’s been my experience that most spammers have terrible grammar, even to the point of being nonsensical. Whether this is because English isn’t their native language, the comment is computer-generated, or some other reason, I couldn’t say. Whatever the case, it’s something to keep an eye out for.
Remember; a comment may have one or more of these features and still be perfectly legitimate. When in doubt, ask yourself this: What value does this comment provide to my readers? If you find yourself on the low or negative end of the spectrum, toss the comment without a second thought.
Selectable Items per Page Hack for Drupal 6 Views
I’m sure regular contributors to Drupal will cringe at what I’m about to show you, but I found it to be a handy trick. Let’s say you’re using the Views module in Drupal 6 and you want a way to dynamically control the number of items listed in a view. In my case, a client I was working for wanted to be able to select the number of products displayed per page.
Reasonable request, right? Unfortunately, Views doesn’t handle it out of the box. After a bit of fiddling, I managed to come up with the following hack. Mind you, I use the term “hack” here literally; you should never edit a module like this if you can avoid it, if only because it makes updates painful later on.
The operative code is in the pre_execute() function on line 1795 of modules/plugins/views_plugin_display.inc. It normally looks like this:
$this->view->set_items_per_page($this->get_option('items_per_page'));
As the name suggests, anything you feed to this function will set the number of items displayed by the view. In my case, I wanted to use a URL variable coupled with a drop-down menu and some jQuery to toggle it, so I changed it like so:
$this->view->set_items_per_page((($_GET['items-per-page'] > 0) ? $_GET['items-per-page'] : $this->get_option('items_per_page')));
Voila! One line of code and you’re off to the races. Type ‘?items-per-page=X’ into the URL (with X being a number, of course) and it should work like a charm. The pagination even follows suit.
For those who want the full solution, here’s the code for the drop-down menu. You’ll need to add it to a view-specific template file. Just follow the pattern to create your own items per page options.
<?php $items_per_page_override = ($_GET['items-per-page'] > 0) ? $_GET['items-per-page'] : 12; ?>
<div id="items-per-page-selector"><strong>Items per Page:</strong> <select>
<option value="12"<?php echo ($items_per_page_override == 12) ? ' selected="selected"' : ''; ?>>12</option>
<option value="18"<?php echo ($items_per_page_override == 18) ? ' selected="selected"' : ''; ?>>18</option>
<option value="24"<?php echo ($items_per_page_override == 24) ? ' selected="selected"' : ''; ?>>24</option>
<option value="9999"<?php echo ($items_per_page_override == 9999) ? ' selected="selected"' : ''; ?>>All</option>
</select>
And here is the jQuery that controls the behavior of the drop-down menu.
$(document).ready(function(){
$('#items-per-page-selector select').change(function(){
window.location = '?items-per-page=' + $(this).val();
});
});
Is SEO an Art or a Science?
I’ve been asked a lot of interview questions in my career, some more creative than others, but few have ever stumped me as much as this one: Is SEO an art or a science?
Think about it for a minute. You may have a strong opinion one way or another; I know people who fall on both sides of the spectrum. If you’re anything like me, you have difficulty deciding one way or the other. Here was the answer I gave to the interviewer.
SEO Begins with Art…
Choosing keywords and planning search strategy are largely intuitive tasks. Experience helps, but in the beginning, all you have to follow is your gut. You take the tools and techniques at your disposal, divine the business objectives at work, feel out the semantics between keywords and user intent, and finally draw up a plan for success.
…and Ends with Science
That’s where measurement and scientific methodology take over. You test, analyze, optimize, and repeat. You observe your work in its natural environment, collect data, and refine the equation until your site is a humming engine of SEO perfection.
What do you think? Are you a firm believer one way or the other, or do you believe SEO is a mix of art and science like I do? Share your thoughts in the comments.
How to Manage External Pages within WordPress
Let’s say you install WordPress in a subdirectory of your site, but you want to use it to manage specific pages in the root directory, as well. The ideal solution would be to move the entire WordPress installation into the root directory, but that may not always be feasible. As it turns out, you can use the following .htaccess code to accomplish the task without moving WordPress or changing any URLs:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} existing-filename.php
ReWriteRule . /wordpress-directory/wordpress-nicename/ [P,L]
</IfModule>
The code above should go into the .htaccess file in your base directory, not in your WordPress directory. Change existing-filename.php to the relative file path of the file you’d like to manage from within WordPress, change wordpress-directory to the name of the directory where WordPress is installed, and change wordpress-nicename to the URL path of the page within WordPress that you’d like to substitute for the original.
Voila! Whatever you’ve got on the page within WordPress should now show up when users go to the original URL. Mesh your WordPress template with the rest of your site design and they won’t even realize the bait and switch.
Elsewhere: How to Cross-Post WordPress to a Facebook Fan Page
I just posted How to Cross-Post WordPress to a Facebook Fan Page on BoldInteractive.com.
Let’s say you want to cross post to a Facebook fan page rather than a profile. Sounds easy, right? After all, it’s fairly trivial to post to a profile. Far from it.As it turns out, the path to Facebook fan page integration is a bit more complex. Here’s what we used for Bold.
Read the whole article on BoldInteractive.com
Internet Explorer Must Be Stopped

Casual web users probably find this chart amusing, but my fellow web professionals know how close it comes to the truth. Today, I’d like you to take note of the giant yellow section in the top, right-hand corner that indicates, “Time spent trying to get the bastard to work in Internet fucking Explorer.”
In case you don’t already know, Internet Explorer is an abyssmal web browser. Here are just a few reasons why.
- It’s insecure. Due in part to its popularity and in part to its security vulnerabilities, Internet Explorer is frequently targeted by hackers as an easy way to spread viruses. I’m not a desktop support specialist, but every time I help someone out with their computer, I advise them to download something else for their web browsing, if only out of security concerns.
- It creates more work for web developers. CSS is the language that controls how websites are supposed to display. On almost every website I build, I have to make special CSS to deal with improper implementation in the three most popular versions of Internet Explorer. Yes, that’s custom styling for each of them individually. Internet Explorer is the only browser that needs such special handling. Multiply this by the number of websites being created by web developers every day and we’re talking about centuries of wasted man hours.
- It doesn’t automatically update. Google Chrome and Mozilla Firefox both update automatically. Thus, if security vulnerabilities or bugs ever crop up, they’re patched rapidly in every distribution of the software connected to the internet. This is how it should work. Internet Explorer doesn’t do this; if you get an update, it only comes as an update to your core Windows installation. As proof, look at the larger percentage of users still using Internet Explorer 6, now two full versions behind the main software. If anything has lead to Internet Explorer’s pervasive security and compatibility problems, it’s this.
- It’s always playing catch-up. Tabbed browsing, for example, really came into vogue in the past few years, but for the longest time, Internet Explorer has refused to embrace it like its competitors. Sure, it’s got tabs now, but its implementation of tabs is terrible compared to Chrome or Firefox. One gets the sense that Microsoft wants to dictate what users want rather than listen and truly innovate.
- It’s only popular because it is the default on computers running Windows. Period. If people were given the choice right from the start, Internet Explorer would have lost the browser battle long ago. The fact is, most people don’t even realize they have a choice.
If you use it, chances are good you don’t know any better; after all, it’s what came on your computer. Let this be your wake-up call. You have alternatives. Google Chrome and Mozilla Firefox are outstanding, completely free, more secure, and offer an all-around better user experience than IE.
I believe in this strongly enough that I’ve signed Ward on the Web up as a supporter of IE 6 No More. If you visit Ward on the Web in IE 6, you’ll get a special message telling you that you need to upgrade.
Personally, though, I don’t think that goes far enough. Internet Explorer has a bad enough history that the most up-to-date versions should be suspect. Thus, I proudly advocate that not only IE 6, but all versions of Internet Explorer, should be discarded in favor of better alternatives.
So, please, for your own sake and the sake of the internet, if you’re reading this in Internet Explorer, it’s time to upgrade. Download Chrome or Firefox and never look back.
Elsewhere: Google Analytics Visitor Counts by Hour of Day and Day of Week
I just posted Google Analytics Visitor Counts by Hour of Day and Day of Week on BoldInteractive.com.
Good news and bad news. I’m a
pessimistrealist, so we’ll start with the bad news. Bad news: Your web team says the site has to go down for maintenance. For several hours in the near future, your company’s presence on the web will be invisible to any potential customer. Good news: You get to [...]