programming
Adding author name to the Drupal search index
TuesdayApr 01,2008
Awhile back, I wanted to add author names to the Drupal search index. After poking around a bit, I found that this was actually pretty easy. I created a new module called custom_helper and in it put the following function:
<?php //Adding author name to the search index function custom_helper_nodeapi($node, $op, $arg = 0) { switch ($op) { case 'update index': if ($node->uid) { return $user->name; } } ?>
Adding to $items in a Drupal view
MondayMar 17,2008
I recently needed to add an extra link to the end of my $items list in a list view and found that this could be done quickly in template.php.
I set out to do two things:
- add a link to the end of my list view that does not contain node data
- as part of this last list item, include a custom link that changes depending on the name of the view
Accomplishing this was a lot easier than I expected. All I had to do was add a switch statement for the view name, and also add a line with the content I wanted to add to my $items array before the theming function.
Displaying Nodeprofile Fields for a User within a Node
SundayFeb 03,2008
I was banging my head against the wall this weekend trying to remember how to display nodeprofile fields with user information. It's actually really easy and I thought I should write a post about how to do it for the next time I forget.
In this case, I have a content type called 'myuserprofile' that is selected as the content type to use for nodeprofiles. In my myuserprofile content type, I have a field for users to enter their favorite food.
Drupal Permissions Issues: A Debugging Checklist
SaturdayJan 12,2008
Every once in awhile, when working on a Drupal site, my content either disappears or I cannot log-in. At this point, I usually get rather angry and start thinking of worse case scenarios. What if I can never log into my site again? What if anonymous users can't read articles?
In a rare moment of clarity, I put together the following Drupal permissions debugging checklist. I hope that you find it as useful as I have.
1. Check user access control and make sure that all users can "access content"
Path: mysite.com/admin/user/access
Drupal Theming: Create a Subpage Template that Applies to Multiple Pages on a Newspaper Site
SundayJan 06,2008
While working on a new Drupal site, I needed to set the same "subsection" template for multiple pages. The site is for an online newspaper and I wanted to use a new template for each of the section homepages. A good example of a similar approach is on CNN.com, where the US section page looks different than both the homepage and the article pages.
PickyRacer.com Up and Running
MondayDec 31,2007
I finally launched PickyRacer.com. PickyRacer is designed to help connect runners with great marathons, half-marathons, and other races. It is built with Drupal 5.3. In the next few months, I hope to add runner blogs, and groups. There are a bunch of other features that I would like to add as well, but I figure I should start small.
Here are some of the more useful modules I used when developing the site:
CCK
Views
Views Bookmarks
Google Analytics
XML Sitemap
Node Teaser
Link
Fivestar
Forward
Location
Node Comment
Path Auto
Javascript Blogroll Randomizer
WednesdayAug 15,2007
Eric uses Blogger and wanted to have a random list of 10 blogs from his blogroll display each time someone visited his blog. Since Blogger doesn't let its members upload PHP files, I used the following Javascript to create a random blog listing for him. The code is a slightly modified version of what I found here.

