分面 API:文本框筛选器



我正在寻找一种方法来添加文本框过滤器,以便在Drupal7中搜索facet api。我的网站有三种内容类型(A、B、C)用于搜索。

我看到我可以在管理员 ->配置 ->搜索和元数据 ->搜索 API(编辑一个,然后过滤器选项卡)中激活一些过滤器,但我看不到其中一个文本。分面 API 中是否有用于过滤器的文本字段?

目前,我使用 Facet API 和 Drupal 搜索,但问题是,如果我过滤内容 A 并在搜索某些内容(例如"Andrew")后重置过滤器并搜索所有内容。我想过滤,如果我搜索某些内容,请搜索过滤的内容,而不是在新搜索中搜索。

我已经在谷歌上搜索过,但我没有得到解决方案。这里报告了同样的问题,有一个临时解决方案,但我想知道是否有更好的解决方案:

  • https://www.drupal.org/node/1381524
  • https://tech-tamer.com/drupal-7-refining-a-faceted-search-with-an-exposed-filter-solved/

也许你可以处理urls,从参数重建url以自动检查分面:

/**
* 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 
}

最新更新