templates

Adding Images to Search Results (Drupal Search)

For a while (earlier in my Drupal career), I was avoiding adding imagefield-attached images to nodes that appeared in my search results, because I remember the first time I tried doing so, I was still quite confused by the way drupal handled search results theming.

Well, after another crack at it, I finally have a nice, performant way of displaying images from nodes added via imagefields (or in drupal 7, image fields) inline with search results, and it didn't require much work at all!

Images in Search Results

The image above shows inline images for LOLSaints.com, a site which uses Midwestern Mac's Hosted Apache Solr search service to return results quickly and allows faceting, etc. using the excellent Apache Solr Search Integration module. But the technique I'm using works equally well with built-in (but slower) Drupal core search module's results.

Adding a class to <body> in a module in Drupal 7

In Drupal 6, I would often resort to using my theme's template.php file to implement template_preprocess(), and add in the class to Drupal's $body_classes array. In Drupal 7, some new hooks were introduced that allow me to do this more easily, and inside my .module files.

Introducing hook_preprocess_HOOK()

<?php
/**
* Implements hook_preprocess_HOOK().
*/
function custom_preprocess_html(&$vars) {
 
$vars['classes_array'][] = 'my-class-here';
}
?>

The Storm Before the Calm - Help Drupal Designers!

With less than two weeks remaining until Drupal 7's 'code freeze,' when new features and major patches will no longer be added to Drupal 7 (instead, everyone will work to optimize and clean up all the approved patches/features for an official Drupal 7 release), it's crunch time for those wishing to make Drupal a dream for designers and themers.

Initially, I had a lot of time to help along with a bunch of other great Drupal users (new and veteran alike) to help nail down a better set of core template files (.tpl.php files), along with some CSS definitions, in order to allow people to code new (and hopefully better) themes straight from Drupal core, using nothing but CSS and a .info file. (See the Stark theme (built into Drupal 7) for an example of how simple a Drupal theme can truly be!).

We've made it through:

Subscribe to RSS - templates