drupal 6

Using the Drupal 6 files table for uploads

Drupal 6 provides a files table for managing files in your custom modules, but the correct usage isn't well/obviously documented. The following code works best in my experience:

$file = new stdClass();
$file->filename = file_munge_filename(trim(basename($_FILES['files']['name'][$source]), '.'), $extensions);
$file->filepath = $_FILES['files']['tmp_name'][$source];
$file->filemime = file_get_mimetype($file->filename);
$file->filesize = $_FILES['files']['size'][$source];
$file->uid = $user->uid;
$file->status = FILE_STATUS_TEMPORARY; //'FILE_STATUS_PERMANENT'

Displaying CCK field data in Solr results

The Apache Solr Search module adds a lot of functionality to the base Drupal system. You can easily search by title, body, and CCK fields. One you'll often run into is many times the designer and/or client wants CCK field data in the search results. You can easily search, and filter by the CCK fields, but how do you get them back out of the Solr index to display? You could do something extremely inefficient like running node_load() for every returned node ID, but there are better answers.

Rename/Reorder Apache Solr options in Drupal 6

There are two ways to rename the sorting methods available in the Drupal 6 Apache Solr module. First is the simpler method of changing the translation of the sort title as it is passed through t(). Second is changing the available sorts in the query object in a custom module. If you need to re-order, changing the query object is your only option. The default available sorts are listed in Solr_Base_Query.php:

/**
* Returns a default list of sorts.
*/
protected function default_sorts() {
// The array keys must always be real Solr index fields.

Subscribe to drupal 6