Skip to content

Commit

Permalink
Create a search page using Drupal views (#4060)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffneybare authored Feb 8, 2024
1 parent 1aa56a6 commit c7eb1ac
Show file tree
Hide file tree
Showing 20 changed files with 1,035 additions and 46 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"minimum-stability": "dev",
"description": "DKAN Open Data Catalog",
"require": {
"drupal/facets": "^3.0@beta",
"drupal/moderated_content_bulk_publish": "~2.0.20",
"drupal/search_api": "^1.15",
"drupal/select_or_other": "^4.1.0",
Expand Down
5 changes: 5 additions & 0 deletions docs/source/developer-guide/dev_search.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
DKAN Search
===========

If you plan to build your data site with a Drupal theme rather than a decoupled frontend the metastore_search module provides a dataset search view that you can use as a starting point.

.. include:: ../../../modules/metastore/modules/metastore_facets/README.md
:parser: myst_parser.docutils_
2 changes: 1 addition & 1 deletion docs/source/installation/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Installation
===============
=============

.. note::
`DKAN DDEV Add-on <https://getdkan.github.io/ddev-dkan/>`_ is a project
Expand Down
22 changes: 22 additions & 0 deletions modules/metastore/modules/metastore_facets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Metastore Facets

This is an optional module for sites that are not using a decoupled frontend. It provides example Categories, Tags, and Publishers facet blocks that you can use with the *dkan_dataset_search* view.

drush en metastore_facets

Use the block layout screen at /admin/structure/block, and place the facets into a sidebar region, restrict the display to the /dataset-search page only.

If you do not see the dataset search view, you will need to run the following to get the view and facets working:

composer require drupal/facets:3.0.x-dev

drush en metastore_facets

drush cim --partial --source=modules/contrib/dkan/modules/metastore/modules/metastore_search/config/install

<aside class="admonition warning">
<p class="admonition-title">Existing sites be very careful here</p>
<p>This config import will import the search view as well as new search API config. If you have custom search api configuration be sure to have it exported to code for safe keeping.</p>
</aside>

The search view and facets are for demonstration purposes and provide a starting step for your own implementation.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.dkan
- views.view.dkan_dataset_search
module:
- search_api
_core:
default_config_hash: 24nvP8tTnc1gmRfiaIIsRgxR-oXY1zDc8vSeTnenU0k
id: categories
name: Categories
url_alias: theme
weight: 0
min_count: 1
missing: false
missing_label: others
show_only_one_result: false
field_identifier: theme
facet_source_id: 'search_api:views_page__dkan_dataset_search__dataset_search'
widget:
type: checkbox
config:
show_numbers: true
soft_limit: 0
show_reset_link: true
reset_text: 'Show all'
hide_reset_when_no_selection: true
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: and
use_hierarchy: false
keep_hierarchy_parents_active: false
hierarchy:
type: taxonomy
config: { }
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
active_widget_order:
processor_id: active_widget_order
weights:
sort: 20
settings:
sort: DESC
count_widget_order:
processor_id: count_widget_order
weights:
sort: 30
settings:
sort: DESC
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
hierarchy_processor:
processor_id: hierarchy_processor
weights:
build: 100
settings: { }
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.dkan
- views.view.dkan_dataset_search
module:
- search_api
id: publishers
name: Publishers
weight: 0
min_count: 1
missing: false
missing_label: others
url_alias: publishers
facet_source_id: 'search_api:views_page__dkan_dataset_search__dataset_search'
field_identifier: publisher__name
query_operator: and
hard_limit: 0
exclude: false
use_hierarchy: false
keep_hierarchy_parents_active: false
hierarchy:
type: taxonomy
config: { }
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
widget:
type: checkbox
config:
show_numbers: true
soft_limit: 0
show_reset_link: true
reset_text: 'Show all'
hide_reset_when_no_selection: false
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
empty_behavior:
behavior: none
only_visible_when_facet_source_is_visible: true
show_only_one_result: false
show_title: false
processor_configs:
active_widget_order:
processor_id: active_widget_order
weights:
sort: 20
settings:
sort: DESC
count_widget_order:
processor_id: count_widget_order
weights:
sort: 30
settings:
sort: DESC
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
hierarchy_processor:
processor_id: hierarchy_processor
weights:
build: 100
settings: { }
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.dkan
- views.view.dkan_dataset_search
module:
- search_api
_core:
default_config_hash: 5l9y65p885oRNMqrRRM4GHCPi8QjjR73QdW86S7hNao
id: tags
name: Tags
url_alias: tags
weight: 0
min_count: 1
missing: false
missing_label: others
show_only_one_result: false
field_identifier: keyword
facet_source_id: 'search_api:views_page__dkan_dataset_search__dataset_search'
widget:
type: checkbox
config:
show_numbers: true
soft_limit: 0
show_reset_link: true
reset_text: 'Show all'
hide_reset_when_no_selection: false
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: and
use_hierarchy: false
keep_hierarchy_parents_active: false
hierarchy:
type: taxonomy
config: { }
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
active_widget_order:
processor_id: active_widget_order
weights:
sort: 20
settings:
sort: DESC
count_widget_order:
processor_id: count_widget_order
weights:
sort: 30
settings:
sort: DESC
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
hierarchy_processor:
processor_id: hierarchy_processor
weights:
build: 100
settings: { }
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: search_api__views_page__dkan_dataset_search__dataset_search
name: 'search_api:views_page__dkan_dataset_search__dataset_search'
filter_key: null
url_processor: query_string
breadcrumb: { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: DKAN Metastore Facets
description: Provides facet blocks for DKAN Metastore Search.
type: module
core_version_requirement: ^9.4 || ^10
dependencies:
- dkan:metastore_search
- drupal:facets
package: DKAN
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
search_facets:
version: 1.0
css:
theme:
css/metastore_facets.css: {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ field_settings:
datasource_id: dkan_dataset
property_path: modified
type: string
nid:
label: nid
datasource_id: dkan_dataset
property_path: search_api_nid
type: string
publisher__name:
label: publisher__name
datasource_id: dkan_dataset
Expand All @@ -41,30 +46,39 @@ field_settings:
datasource_id: dkan_dataset
property_path: title
type: text
title_string:
label: title_string
datasource_id: dkan_dataset
property_path: title
type: string
datasource_settings:
dkan_dataset: { }
processor_settings:
add_url: { }
aggregated_field: { }
custom_value: { }
dkan_dataset_add_nid: { }
dkan_dataset_filter_hidden: { }
dkan_dataset_filter_unpublished: { }
entity_type: { }
ignorecase:
weights:
preprocess_index: -20
preprocess_query: -20
all_fields: false
fields:
- description
- keyword
- publisher__name
- theme
- title
weights:
preprocess_index: -20
preprocess_query: -20
language_with_fallback: { }
rendered_item: { }
tracker_settings:
default:
indexing_order: fifo
options:
index_directly: true
cron_limit: 50
index_directly: true
track_changes_in_references: true
server: dkan
Loading

0 comments on commit c7eb1ac

Please sign in to comment.