I see the "Results Per Page" option in the Solr settings, but it would be nice to be able to provide a few integers that will be shown to the user as a drop-down menu, allowing them to decide how many results they see on a page.

Comments

wonder95’s picture

And what happens when someone wants to have a value that's different from the pre-defined options in the list? I've run into that issue in other modules, and having a text field where you can add whatever value you want is much more flexible.

nick_vh’s picture

Status: Active » Closed (won't fix)

We changed this to allow more flexibility. Not changing again :-)

OldAccount’s picture

Okay, understandable. Can you point me in the right direct of how to override the default $rows variable with a select list of options on the results display for the end user? I've tried to figure it out on my own but I'm still a PHP novice so it's probably way off and I'm not even sure what the function should be named:

function apachesolr_search_search_results($keys = NULL, $conditions = NULL, $search_page = NULL) {
	$params = array();
	$results = array();
	$form['results'] = array(
		'#type' => 'select',
		'#title' => t('Results per page'),
		'#options' => array(
			0 => t('10'),
			1 => t('20'),
		),
		'#description' => t('The number of results that will be shown per page.'),
		'#default_value' => '10',
	);
	$params['rows'] = drupal_render($form);
}

Thank you!

nick_vh’s picture

You need hook_form_alter function. Please look at the Drupal API for more information. This is not solr specific :-)

SandraVdv’s picture

But you need to pass the value from the hook_form_alter field (dropdown for results per page) to the solr query options (to limit them to the correct value)? How do you do that?