module

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'

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.

Add a total number of results to ApacheSolr result pages

By default the Drupal ApacheSolr module does not display the total number of results for a given search. This is how to add it.

For my use it makes sense to add the result total to the Search form using hook_form_[form_id]_alter().


/**
* Implementation of hook_form_[form_id]_alter().
*/
function ms_solr_site_form_search_form_alter(&$form, &$form_state) {
if ($form['module']['#value'] == 'apachesolr_search') { //Will change all searches otherwise.
if (apachesolr_has_searched() && ($response = apachesolr_static_response_cache())) {

Subscribe to module