materiobaseajax module

first ajax geed results
+ 2 different custom autocomplete func (not used for now)
	- deselect
	- searchapi

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy
2012-07-23 23:02:09 +02:00
parent ad7809415c
commit fb30fe966e
7 changed files with 280 additions and 9 deletions
+66 -8
View File
@@ -26,13 +26,21 @@ function materiobasemod_permission() {
*/
function materiobasemod_menu() {
$items = array();
$items['materiobase/search/autocomplete'] = array(
$items['materiobase/search/autocomplete/dbselect'] = array(
'title' => 'Autocomplete materiobase search',
'page callback' => 'materiobase_search_autocomplete',
'page callback' => 'materiobase_search_autocomplete_dbselect',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
'file' => 'materiobasemod.pages.inc',
);
$items['materiobase/search/autocomplete/searchapi'] = array(
'title' => 'Autocomplete materiobase search',
'page callback' => 'materiobase_search_autocomplete_searchapi',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
'file' => 'materiobasemod.pages.inc',
);
return $items;
}
@@ -81,28 +89,79 @@ function materiobasemod_block_view($delta = '') {
return $block;
}
/**
* Implements hook_block_view_alter().
*/
function materiobasemod_block_view_alter(&$data, $block) {
if ($block->module == 'search_api_page') {
$page = search_api_page_load($block->delta);
$item = menu_get_item();
if (isset($page->path) && $page->path == $item['path']) {
$keys = arg(count(arg(NULL, $page->path)));
if ($keys) {
$data['content']['keys_' . $page->id]['#default_value'] = $keys;
$data['content']['keys_' . $page->id]['#value'] = $keys;
}
}
}
}
/**
* Implements hook_entity_info_alter().
*/
function materiobasemod_entity_info_alter(&$entity_info) {
$entity_info['node']['view modes']['cardsmall'] = array(
'label' => t('Small card for the grid'),
'custom settings' => TRUE,
);
$entity_info['node']['view modes']['cardmedium'] = array(
'label' => t('Medium card for the grid'),
'custom settings' => TRUE,
);
$entity_info['node']['view modes']['cardbig'] = array(
'label' => t('Big card for the grid'),
'custom settings' => TRUE,
);
}
/**
* Implements hook_preprocess_node().
*/
function materiobasemod_preprocess_node(&$vars) {
$vars['theme_hook_suggestions'][] = 'node__'.$vars['view_mode'];
$vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode'];
// dsm($vars, '$vars');
}
function materiobasemod_preprocess_field(&$vars) {
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#view_mode'];
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_type'] . '__' . $vars['element']['#view_mode'];
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_name'] . '__' . $vars['element']['#view_mode'];
// dsm($vars, '$vars');
}
/**
* materiobase_search_form()
*/
function materiobase_search_form(){
$form = array();
$form['searchfield'] = array(
'#type' => 'textfield',
'#default_value' => '',
'#autocomplete_path' => 'materiobase/search/autocomplete',
// '#autocomplete_path' => 'materiobase/search/autocomplete/searchapi',
'#autocomplete_path' => 'materiobase/search/autocomplete/dbselect',
'#size' => 30,
'#maxlength' => 1024,
// '#element_validate' => array('taxonomy_autocomplete_validate'),
);
$form['create'] = array(
'#type' => 'submit',
'#value' => t('Search'),
);
return $form;
}
@@ -115,4 +174,3 @@ function template_preprocess_materiobase_search_block(&$vars){
}