Skip to content

Search Page (customisations)

Peter Stokes edited this page Feb 13, 2020 · 6 revisions

WORK IN PROGRESS: this page contains fragments of instructions that will be reorganised at a later stage.

WARNING: any logical or syntax error in your files may stop your Archetype instance from working. Please make sure you make a copy of the local_settings.py file before and after editing it so you can always revert to a working configuration. Modifying the search won't break your data, so you don't necessarily have to backup your whole instance before proceeding.

Level: intermediate level of Python

Prerequisites

Most of the search page user interface is defined by a large python dictionary called FACETED_SEARCH included in your Archetype instance: https://github.com/kcl-ddh/digipal/blob/master/digipal/views/faceted_search/settings.py

Any customisation to the search interface requires you to modify that python dictionary in your local_settings.py file. You can create the file if it doesn't already exist. That file should be located under the digipal folder, at the same level as urls.py.

First you'll need to import the FACETED_SEARCH dictionary and its helper class FacettedType:

from digipal.views.faceted_search.settings import FACETED_SEARCH, FacettedType

How do I tell Archetype to load my changes?

You will normally need to restart Archetype's web server in order to force it to load your changes. For details on how to do this, see Telling Archetype to Load Changes.

How do I change the label of a column in the faceted search?

By default Archetype assumes that your documents are manuscripts and they have a reference code called a shelfmark.

Imagine that you are working only with inscriptions instead of manuscripts. You would then patch the dictionary in the following way:

# get the MS type from the FACETED_SEARCH dictionary
# https://github.com/kcl-ddh/digipal/blob/master/digipal/views/faceted_search/settings.py#L62
manuscripts = FacettedType.fromKey('manuscripts')

# we change the display label of manuscript type to 'Inscriptions'. Note that the key remains 'manuscripts'.
manuscripts.options['label'] = 'Inscriptions'

# change the label of the shelfmark field https://github.com/kcl-ddh/digipal/blob/master/digipal/views/faceted_search/settings.py#L90
shelfmark = manuscripts.getField('shelfmark')
shelfmark['label'] = 'Inventory number'
Clone this wiki locally