Syndicate content

Drupal Planet

for the Drupal Planet RSS feed
Mark Jarrell's picture

Presentation on Building a Mobile Drupal Site

I was lucky enough to be able to give another presentation at this year's excellent DrupalCamp Nashville, sponsored by Music City Networks, 7 Sudos, Tropo, The Tennessean, and a number of other splendid companies. This year, I decided to present on the Austin Peay State University mobile website that I've been building for the past few months along with the help of interns Jason Bell, Brian Barbour, APSU staff Rollow Welch, Terry Damron, Bill Persinger, and Ryan Forsythe.

Mark Jarrell's picture

Adding an Additional CCK Validation Function on a Field Using hook_form_alter

Although CCK automatically does some basic validation on your fields that you add to your Drupal content types, there are some cases where you'd like to do some additional validation for your site. One use case that I ran into recently was a basic text field that was being used to house hyperlinks for one of my websites. The text field had already been in place and working perfectly for months. Rather than do something drastic like replacing the field altogether with a field provided by the "Link" module, I decided to do a hook_form_alter to add in my own custom validation function.

Mark Jarrell's picture

Changing the Length of User Sessions in Drupal

I was recently trying to figure out exactly how long my users' sessions were lasting on an existing Drupal site that I had built. Generally it seemed like users were remaining logged in for an extremely lengthy period of time. I did some research and finally discovered that this setting is actually configured in the default settings.php file that ships with Drupal. There's a line in the settings file that initially reads:

ini_set('session.cookie_lifetime',  2000000);

Mark Jarrell's picture

Programmatically Adding Pre-Built Option Lists to Drupal Webforms

I'm a huge fan of the Webform module (and building Drupal forms in general), and I just today noticed a feature I hadn't previously taken advantage of. This is the ability to programmatically add what are called "pre-built" option lists that can be used in your webforms.

Webform pre-built options list in action

Mark Jarrell's picture

Adding Zebra Striping CSS to Webform Fields and Formatting the Emails It Sends

Ever wanted to add alternating background colors (a.k.a. "zebra stripes") to your webform fields? I had a need to do this a couple of days ago and struggled to find a method for this. Little did I know that the webform module actually has a few template files included with it that you can use to override what's going on in the theme layer.

The particular thing I wanted to do was to add some CSS to the webform fields so that I could do some easy CSS zebra striping. I know this is super easy to do with the output of the Views module because of the "row-even" and "row-odd" CSS classes that are provided out of the box. I wanted to be able to do some similar CSS classes on my webform fields. Getting the job done requires taking the "webform-form.tpl.php" default template file in the Webform module directory and copying it to own your custom theme directory.

Here's the code I ended up using:

Mark Jarrell's picture

Adding an .htaccess Rule to Make Simpler Links to Drupal Files

In a site I was recently working on, I found myself hard-coding links to files stored within my Drupal site's "files" directory. If you've ever coded these links before, you know that they normally look something like:
/sites/[sitename]/files/[someotherdirectory]/image.jpg

This can be somewhat painful to add to the site, especially if you have any plans to ever change the domain name of your site. It would really be ideal if you could leave the domain name out of the equation and just write the link in the format:
/files/[someotherdirectory]/image.jpg

This is actually possible to do using the .htaccess file that appears in the root of your Drupal installation. Basically you just need to add a single line:
RewriteRule ^files/(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]

After you implement this rule, you should be able to start writing simpler links to your "files" directory.

Happy coding!

Image of the rewrite rule and the alternate links. See PDF on DIWD Site.

Mark Jarrell's picture

DrupalCamp Colorado Form Alterations Presentation Files

Yesterday, I gave a presentation at DrupalCamp Colorado entitled "Form Alterations - Getting What You Want in Drupal Without Hacking". I wanted to make sure that everyone has access to the files from the presentation, so here those are:

Session Page:
http://drupalcampcolorado.org/sessions/form-alterations-getting-what-you...

Slides:

File: 
Mark Jarrell's picture

Building a Firefox Search Add-on For Drupal.org

I was having trouble locating a good Firefox search add-on for searching drupal.org. A Google search or two reveals a couple of add-ons created by community members in the past couple of years that do searches of drupal.org via a Google search (using the "site:drupal.org" keyword). I know, however, that the searches on drupal.org recently received an overhaul (using Apache Solr) and now, searching on the actual drupal.org search is actually more efficient than a Google search in many cases. Especially if you know how to make quick use of the right sidebar of the search page which makes use of faceted search.

I knew it couldn't be that difficult to build a search plugin for Firefox, so I began searching the Mozilla site for instructions on that. If you're interested in doing this on your own, you can find out how to build what's called an "OpenSearch plugin" for Firefox at: Creating OpenSearch plugins for Firefox

If you'd like to download the add-on that I built and begin searching Drupal.org from Firefox, click on the screenshot below:

Drupal.org Search add-on in action

Mark Jarrell's picture

Using FlashVideo for User-Contributed Video: A Drupal Tutorial

This video/tutorial was initially started as a presentation for the Denver Open Media Conference this weekend. Since we had a snowstorm on the day of my session, I decided to do this as a screencast here instead. My description of the session and the screencast appear below:

Mark Jarrell's picture

Adding a Reset Button to Exposed Views Filters

I'm a big fan of using exposed filters in my administrative views that I build. One thing that had escaped me until today was that there isn't always a really easy way for my users to get back to square one. I need a reset button. Don't we all? I did some searching around and some experimenting. It turns out that you can do this really easily in a custom module just using a hook_form_alter(). You can see the result in the screenshot below. Easy reset button.