facet api: textbox filter

albert Source

I'm looking to a way to add a textbox filter for searches of facet api in Drupal7. My site has three content type (A,B,C) that is used in searches.

I see that I can activate some filters in Admin -> configuration -> search and metadata -> Search API (edit one and then filters tab), but I can't see one of text. Is there a text field for filter in facet api?

Currently, I use Facet API and Drupal search, but the problem is that if I filter for content A and after I search something ("Andrew" for example) it resets the filter and search in all contents. I would like to filter and if I search something, search on the filtered content, not in a new search.

I have searched on Google, but I don't get a solution. The same problem is reported here, with a temporal solution, but I wnat to know if there is a better solution:

drupaldrupal-7

Answers

answered 6 days ago Fky #1

Maybe You can deal with urls , reconstruct url from parameters to automatically check facets :

/**
 * Implements hook_facetapi_searcher_info().
 *
 * @see hook_facetapi_searcher_info_alter()
 */
function MYMODULE_facetapi_searcher_info_alter(array &$searcher_info)
{
    foreach ($searcher_info as $key => $value) {
        if ($value['url processor'] == 'pretty_paths') {
            $searcher_info[$key]['url processor'] = 'mymodule_urlprocessor';
        }
    }
}

/**
 * Implements hook_facetapi_url_processors().
 *
 * @see hook_facetapi_url_processors()
 */
function MYMODULE_facetapi_url_processors()
{
    return array(
        'mymodule_urlprocessor' => array(
            'handler' => array(
                'label' => t('My URL processor'),
                'class' => 'FacetapiUrlProcessorMyModule',
            ),
        ),
    );
}

class FacetapiUrlProcessorMyModule extends FacetapiUrlProcessorPrettyPaths {

 // overrides methods to construct url 
}

comments powered by Disqus