search field default value : search among our n cards
This commit is contained in:
parent
8672e5eb9f
commit
eeccd6a4d2
@ -419,19 +419,30 @@ function materio_search_api_search_form($form, &$form_state){
|
|||||||
global $user;
|
global $user;
|
||||||
$form = array();
|
$form = array();
|
||||||
|
|
||||||
|
|
||||||
$args = arg();
|
$args = arg();
|
||||||
$path = array_shift($args);
|
$path = array_shift($args);
|
||||||
$keys = implode('/', $args);
|
$keys = implode('/', $args);
|
||||||
|
|
||||||
|
if(user_access('use materio search api autocomplete')){ // use materio search api autocomplete | use materio search api filters
|
||||||
|
$query = new EntityFieldQuery();
|
||||||
|
$query->entityCondition('entity_type', 'node')
|
||||||
|
->entityCondition('bundle', 'materiau')
|
||||||
|
->propertyCondition('status', 1);
|
||||||
|
$count = $query->count()->execute();
|
||||||
|
$default_value = t("search among our !fiches cards", array("!fiches"=>$count));
|
||||||
|
}else{
|
||||||
|
$default_value = '';
|
||||||
|
}
|
||||||
|
|
||||||
$form['searchfield'] = array(
|
$form['searchfield'] = array(
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#default_value' => $path == 'explore' ? $keys : "", // TODO: set the search page path global or a variable in settings
|
'#default_value' => $path == 'explore' ? $keys : $default_value, // TODO: set the search page path global or a variable in settings
|
||||||
// '#value' => $keys,
|
// '#value' => $keys,
|
||||||
'#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
|
'#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
|
||||||
//'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
|
//'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
|
||||||
'#size' => 30,
|
'#size' => 30,
|
||||||
'#maxlength' => 1024,
|
'#maxlength' => 1024,
|
||||||
|
'#attributes' => array("default"=>$default_value),
|
||||||
);
|
);
|
||||||
|
|
||||||
if(user_access('use materio search api filters')){
|
if(user_access('use materio search api filters')){
|
||||||
|
@ -52,7 +52,6 @@ function materio_search_api_autocomplete_dbselect($typed = ''){
|
|||||||
}
|
}
|
||||||
|
|
||||||
drupal_json_output($term_matches);
|
drupal_json_output($term_matches);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,7 +165,16 @@ function materio_search_api_results_search(){
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if(user_access('use materio search api')){
|
if(user_access('use materio search api')){
|
||||||
$index_machine_name = variable_get('mainsearchindex_'.$language->language, -1);
|
// switch index depending on key words type full text or taxonomy term (autocomplete selection)
|
||||||
|
$searchmode = isset($user->data['materiosearchapi_searchmode']) ? $user->data['materiosearchapi_searchmode'] : "fulltext";
|
||||||
|
switch($searchmode){
|
||||||
|
case "fulltext":
|
||||||
|
$index_machine_name = variable_get('mainsearchindex_'.$language->language, -1);
|
||||||
|
break;
|
||||||
|
case "taxonomy":
|
||||||
|
$index_machine_name = variable_get('taxonomysearchindex_'.$language->language, -1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
$index = search_api_index_load($index_machine_name);
|
$index = search_api_index_load($index_machine_name);
|
||||||
}else if(user_access('use materio search api for breves')){
|
}else if(user_access('use materio search api for breves')){
|
||||||
$index_machine_name = variable_get('brevessearchindex_'.$language->language, -1);
|
$index_machine_name = variable_get('brevessearchindex_'.$language->language, -1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user