What is Drupal?

Submitted by Barrett on Mon, 02/28/2011 - 05:10
What is Drupal?

What is Drupal?

In preparation for his upcoming keynote at DrupalCon Chicago, Dries has posted a request on his blog that Drupal users answer the question of what Drupal is to them. My answer to the question is:

Drupal is the lackey that I force to write the boring, repetitive code (e.g., log in/log out, change password, database CRUD operations) so that I can focus on the interesting problems.

Before I came across Drupal, I was free-coding all my PHP and getting bored and frustrated doing it. System after system, I spent most of my time writing the same code (with minor variations) over and over. System after system, users wanted to change page content and it came to me in change requests. Drupal got me out of doing all that. It handles the grunt code for and it lets me turn content editing responsibility over to the site owners. With that stuff done for me, I can turn my time to more interesting and "value-added" aspects of the systems I build.

Barrett Mon, 02/28/2011 - 05:10

Creating a Memory game

Submitted by Barrett on Sat, 02/05/2011 - 11:07
Creating a Memory game

Backyardigans Memory Game

Playing Memory with the son this morning, I got to thinking about how I would go about building an online version of the game. With a bit of jQuery magic, I don't think it would be too hard.

My off-the-cuff thinking is that it'd take:

  • A set of images, trimmed to a consistent size and ratio to be the "face up" state of the cards. The number of images in the image library would determine how many "cards" could be displayed in a game.
  • An image of the same size and ratio as the aforementioned images to be the "face down" state.
  • Three css class definitions, setting the background-image properties of the cards in each of their states. The "face up" class would display the image, the "face down" would display the generic image, and the "matched" state would display some greyed out state indicating the card in that position was already selected.
  • Some code (probably PHP) to render the correct number of divs in a square rows-and-columns layout. A table and tr/td tags could also work and may be semantically better, actually.
  • Some code (PHP) to randomly assign images to the divs/td's above
  • jQuery code to handle the user interaction, essentially an on-click event that changes the class of the card to display the proper image.
  • Some jQuery to determine if two selected cards were a match

Supporting functionality would include:

  • Admin interface to add/change images in the image library
  • Letting the user choose how big a set of cards they wanted to play (e.g., a 4x4 grid or a 20x20 grid)
Barrett Sat, 02/05/2011 - 11:07

Tags

DrupalCon Chicago

Submitted by Barrett on Thu, 02/03/2011 - 12:51
DrupalCon Chicago

I'm attending DrupalCon Chicago, March 7-10, 2011

There's just over a month left until DrupalCon Chicago. I've been going over the final session list and I'm jazzed. Looks like some great sessions this year. Now I just need to figure out human cloning so I can attend all the sessions I want.

I'm heavily oriented to the Coder track with a smattering of Implementation and Configuration sessions but a couple of the Theming sessions look really interesting as well.

This year's conference page also has a neat feature on the Schedule page: Each session has a button next to it to add it to your schedule (or remove it, if it's already on your schedule). You can then view your customized schedule through a tab on your account page. I haven't seen anything about how they implemented it, but my guess is that it relies on Node Queue. The only thing I'd change about what they've implemented would be to add a print-friendly version of the My Schedule list and maybe a means to export it in iCal or other calendar format.

Barrett Thu, 02/03/2011 - 12:51

Tags

Displaying the main menu as icons

Submitted by Barrett on Wed, 02/02/2011 - 12:47
Displaying the main menu as icons

One of the things I wanted for my DataSmith custom theme was to use images rather than text for the main menu. I found a couple different modules that looked like they'd do what I wanted, but neither quite met my needs. In the end, I resorted to changing the links via a theme hook in my template.php, ala Chris Shattuck's post.

Chris's code, though, didn't work with Drupal 7, so I had to do a little modification to get it working. While this code works with the main_menu display Zen codes into the page.tpl.php file, it does not work with menu blocks. Since writing this, I've come across the Menu Icons module which looks like it will solve this problem in menu blocks...if only it were in D7. My next item of business may be to see if I can get that updated.

/**
* Implements theme_links()
*/
function datasmith_links__system_main_menu($data) {
  // Allows for images as menu items. Just supply the path to the image as the title
  foreach($data['links'] as $name=>$link) {
    if (strpos($link['title'], '.png') !== false || strpos($link['title'], '.jpg') !== false || strpos($link['title'], '.gif') !== false) {

    $variables = array(
      'path' => $link['title'],
      'alt' => $link['attributes']['title'],
      'title' => $link['attributes']['title'],
      'attributes' => array('class' => 'main-menu-image', 'id' => $name . '-image'),
    );
    $link['title'] = $img = theme('image', $variables);
    $link['html'] = TRUE;  //otherwise theme_link will use check_plain on the title
    }
  $data['links'][$name]=$link;
  }
  return theme('links', $data);
}
Barrett Wed, 02/02/2011 - 12:47

A Tabbed Overview Page Using Tabs, CCK Fieldgroups, and Viewfield

Submitted by Barrett on Sun, 09/26/2010 - 15:29
A Tabbed Overview Page Using Tabs, CCK Fieldgroups, and Viewfield

I've been working on a travel site for a friend, highlighting Costa Rica as a tourist destination. To express the things there are to see and do in Costa Rica, I've created four content types:

  • Regions
    - areas of the country
  • Destinations
    - places to go within Regions
  • Tours
    - things you can do at a Destination
  • Hotels
    - places to stay

Hotels and Destinations are linked to Regions by means of a Node Reference field and Tours link to Destinations in the same manner.

What I wanted to do was create a Region overview page that would show the body of the Region as well as all the Destinations and Hotels in the Region. Setting up views for the Hotels and the Destinations and attaching them using Node Content displays was easy. However, since there are a variable number of Destinations and Hotels that might be in a Region, finding a way to easily display them was giving me fits. I decided what I really needed was a tabbed interface so that a user could easily switch back and forth between displaying Destinations or Hotels.

A few quick searches netted me two promising modules: Tabs and CCK Fieldgroup Tabs. The former is a helper module adding in the JQuery UI Tabs plugin. The latter makes it possible to set CCK fieldgroups to display as tabs.

All looked well...then reality set it. The CCK UI would not allow me to move my attached views into the fieldgroups I created. I figured I was going to have to dig into code and start tweaking preprocessing functions to try to get the content of my views into the fieldgroups. Fortunately for me, before going down that path, I threw out the question in the Drupal-Support IRC channel.

Almost immediately, another user came back with the suggestion of Viewfield. This wonderful little module allows you to put the content of a view into a CCK field. Once I had it installed and configured, everything just came together. With no fuss (and no code) I had a clean tabbed interface for showing views content on my Regions.

Barrett Sun, 09/26/2010 - 15:29

Tags

Post Reminder 1.0 released

Submitted by Barrett on Sun, 10/04/2009 - 07:18
Post Reminder 1.0 released

I completed version 1.0 of the Post-Reminder module last night. This version clears up the three major issues I had with the 0.7 version released previously. Users can now see a list of all their reminders from their account page, the Amount of Time field is validated as an integer on reminder creation/editing, and an error is displayed on the reminder creation form if the site administrator has not set any content types as permitting reminders.

I'm torn as to next steps for development. There are several features I'd like to add in, but I also want to work on getting a version working for the coming release of Drupal 7.

Desired features for the next module version:

  • Add a module admin role with permissions to manage module settings.
  • Make reminder messages configurable by admins.
  • Taxonomy based reminders
Barrett Sun, 10/04/2009 - 07:18

Working on new module: A reminder to post

Submitted by Barrett on Sun, 06/28/2009 - 20:35
Working on new module: A reminder to post

I've begun working on a module I'm considering for my capstone project as Capella. What I'm thinking of is a module which will allow users with content creation privileges to set up reminders which will be sent to them if they haven't posted new content to the site in some configurable length of time. Basically, a way to set up a custom nag if you don't post.

I haven't fleshed out all the details, but the broad strokes of what I think it will need are in the attached MindMap file.

Barrett Sun, 06/28/2009 - 20:35

Modifying Form Table module to work in Drupal 6

Submitted by Barrett on Tue, 01/13/2009 - 09:30
Modifying Form Table module to work in Drupal 6

One issue I've struggled with while trying to find my way around Drupal's Form API is that there appeared to be no easy way of putting input elements into a table. The solution is to create new form elements using the elements hook, the process of which has been modularized into the Form Table module. Unfortunately Form Table hasn't, as of this writing, published a version compatible with Drupal 6.

Barrett Tue, 01/13/2009 - 09:30

Tags

"WHO-5 Well-Being Index" module released

Submitted by Barrett on Mon, 01/12/2009 - 08:20
"WHO-5 Well-Being Index" module released

"Initial work on the Drupal version of the WHO-5 Well-Being Index has been completed and I've published a working beta version of the module on the module's Drupal project page.

While this is a working release, the module is not in a finished state yet. Plans for the near future include:

  • Writing a new 'About' page rather than simply stealing text from the WHO-5 site.
  • Restructuring the questions so they are presented in a table format as they are in the original instrument.
  • Improved and prettier interpretation and score reporting
  • Ability for registered users to store their results to a table, permitting longitudinal tracking
  • Longer term, I want to get independent validation of the efficacy of the module as compared with the original version. That is, I want to make sure that the module doesn't somehow skew the scores, thus altering the translation.

One major activity at the moment is digging through the research that has been done on the WHO-5 to ensure that the instrument on which the module is based has sufficient research basis to make it really meaningful as an instrument. So far, the results of initial literature searches aren't yielding as much information as I had hoped. If it becomes apparent that there isn't a significant body of research behind this instrument, I may end up retiring the module and searching out other options.

Barrett Mon, 01/12/2009 - 08:20

DC Doc Sprint

Submitted by Barrett on Sun, 11/09/2008 - 07:06
DC Doc Sprint

Yesterday I headed into the city for the DC Doc Sprint. We had some difficulties because the library had assigned us a room which didn't have wi-fi, but we migrated up to lobby of the Black Studies section and got going there.

My focus was on checking the PHP snippets in the handbook for compliance with formating standards. I used the Coder module with a stub module I wrote to do the checking. Since Coder can't check arbitrary code, I copied the snippets from the documentation pages into my stub module and ran Coder against that module. It worked well enough, but it would have helped a lot if Coder had an interface to allow someone to input arbitrary code for it to test. I've put in a feature request on the Coder issue queue. Maybe it'll make the grade and get implemented.

All in all, the event wasn't as interactive as I had hoped (I had gone as much for the networking as the actual work, being in the common area of the library just didn't support much conversation I felt) but definitely worthwhile. I got a crash course in the Drupal coding standard, learned about the documentation editing and creation process, and met some good people. I'll definitely be going again.

Barrett Sun, 11/09/2008 - 07:06

Tags