6104 comments
2357 subscribers
6264 on Twitter
Subscribe! Feed reader E-mail

Drupal: Finding nodes through autocomplete

The clients wanted a quick way to jump to the latest revision of a node. I was delighted to discover that the Finder module made it easy to create an autocomplete shortcut to nodes and users. It offered way more features than I would’ve coded myself. Finder lets you match nodes on title, author, CCK fields, and so on.

There’s a simpler module called Node Quick Find, but I’m going to go with Finder for now because of the options that Finder offers.

There was one small thing I needed to tweak. Finder Node goes to node/nid, but we’ve got Revisioning set up to view the current revision of a node and not the latest. Fortunately, Finder took that into account and provided enough hooks to let me change the behavior. Here’s what I needed to do:

function mymodule_finder_goto_alter(&$result, &$finder) {
  $finder->base_handler['#module'] = 'mymodule';
}

function mymodule_finder_goto($finder, $result) {
  $vid = revisioning_get_latest_revision_id($result->nid);
  drupal_goto('node/' . $result->nid . '/revisions/' . $vid . '/view');
}

You’ll want to use more if logic if you’re working with different kinds of Finders, of course, but this was enough to handle what I needed. Hooray for hooks!

Finder doesn’t seem to support Features, so I’ll need to configure things again once I move to production. No problem! I’ve added some notes to myself in the issue-tracking system we’re using, and I’ve asked the clients to try this new shortcut out.

Drupal: There’s a module for that.

2011-09-02 Fri 14:17

Short URL: http://sachachua.com/blog/p/22476

On This Day...

  • 2010: Week ending September 5, 2010 — SCHEDULED: 2010-09-06 Mon 8:00 From last week’s plans Work [X] Plan Idea Labs: Follow up on other Idea Labs [X] Classroom to [...]
  • 2009: Weekly review: Week ending September 6, 2009 — From last week’s plans: Work – more planning, tweaking, putting together My team is happy with the improvements I’ve been [...]
  • 2006: Love 2.0 — Photo by Rob Dudley. License: Creative Commons Attribution. Wow. Just wow. Whenever I falter and lose sight of my way, other people lift [...]
  • 2006: Break glass in case of emergency: For homesickness — Dearest Sacha, I read your blog and I see two issues that are bothering you: homesickness and “guilt” for being away from [...]
  • 2005: Fixed — Apparently, all that’s needed to get me past something traumatic are several very good cries and a nice long weekend with [...]
  • 2005: Shameless plug for Software Freedom Day — Celebrate Software Freedom Day on the 10th! It’s a great time to score Linux CDs for people who haven’t tried [...]

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging

Free sample!