-
Notifications
You must be signed in to change notification settings - Fork 2
Search customizations
Maria Fisher edited this page May 11, 2021
·
6 revisions
Details the customizations done to search results found at /resources, /events, and /experts.
This work is primarily done in The WRI search module
Easiest to look at the info file for an initial workup:
- https://github.com/thinkshout/wriflagship/blob/master/profile_work/wri_sites/modules/wri_search/wri_search.info.yml
- https://www.drupal.org/project/facets - creates the filters at the top and side of search results pages.
- https://www.drupal.org/project/facets_pretty_paths - lets you make faceted search results pretty, like https://www.wri.org/resources/topic/economics-10510/region/africa-8911/region/north-america-8940 instead of https://www.wri.org/resources?topic=10510®ions=%5B8911%2C8940%5D
- https://www.drupal.org/project/facets_summary Creates the listing of chosen facets, with an X to clear, for pages like https://www.wri.org/resources/topic/10510
- https://www.drupal.org/project/search_api_autocomplete -- lets you use autocomplete in the search filters. I don’t believe we actually used this.
- https://www.drupal.org/project/search_api_exclude_entity -- Tell Search API not to index certain nodes.
- https://www.drupal.org/project/search_api_solr - Adds solr search compatibility
- https://www.drupal.org/project/search_api_pantheon -- required to use Solr on Pantheon.
There is also custom code within The WRI search module that accomplishes the following things.
- The WRI taxonomy module contains code to alter the canonical url for a Taxonomy term and redirect some terms to the /resources page. This is also described in the Content Editor's Guide
- Several blocks have links to the Resources page based on the fields used to filter the results of the blocks. These values are passed as tokens to the block, then translated into the pretty-path solr value for the same filters. Code for that is found in the WRI Resource link field formatter.
For example, if you create a listing block as detailed in the content editor's guide the default value of the More Link field is
internal:/resources?all_topics=[block_content:field_tag:entity:root:tid]&within_this_topic=[block_content:field_tag:entity:non_orphan]&type_of_resource=[block_content:field_filter_by_resource_type:entity:root:tid]&subtype=[block_content:field_filter_by_resource_type:entity:non_orphan]&tags=[block_content:field_filter_by_tag:target_id]®ion=[block_content:field_filter_by_region:entity:root:tid]&country=[block_content:field_filter_by_region:entity:non_orphan]
which would translate into something likeinternal:/resources?all_topics=123&within_this_topic=456&type_of_resource=789
etc. The code in the "WRI Resource link field formatter" uses the Pretty Path Helper service to turn connect the facet name "all_topics" to the pretty path you'd get if you selected that value for "all_topics".