Skip to content

Advanced Search results: Display string of Query #156

@Monica-Wood

Description

@Monica-Wood

When you have done an Advanced Search and been taken to the corresponding /Search/ endpoint with the results, it displays where the search criteria goes, a string of the search that was performed. Usually along the lines of $field_label : $value $field_label: $value. Such as in the screenshot below:

Image

I have been looking for a way to edit the $field_label of these results and had assumed putting in a label attribute on the advanced search would do this. eg: {{{ca_objects.preferred_labels%label=Title}}} but this isn't working. I am having trouble tracking down the code that sets this and thought I had found it here: https://github.com/collectiveaccess/pawtucket2/blob/master/app/helpers/searchHelpers.php#L887 but nothing I change here seems to change what is shown.

In searchController.php L:271 I found where the criteria is added and followed that to https://github.com/collectiveaccess/pawtucket2/blob/master/app/lib/Browse/BrowseEngine.php#L380. It seems to be setting a parameter criteria_display_strings, but this doesn't seem to be used anywhere else in this flow.

Further down in SearchController https://github.com/collectiveaccess/pawtucket2/blob/master/app/controllers/SearchController.php#L417
I see it's now going through each of the _Search criteria and setting a display string.
It seems to be adding labels based on the attribute labels instead of the label set in the advanced search form, which in most cases that's ok, except for things like relationships, where you might want the label 'Artist' instead of 'Entity Name'.

It is also using list_item_id numbers instead of labels for things like type_id

Image

I have now found a way to show what I want by bringing the SearchController and SearchHelper over to my theme and setting a var based on $vs_search_expression_for_display in the controller and uncommented this line in the helper https://github.com/collectiveaccess/pawtucket2/blob/master/app/helpers/searchHelpers.php#L904

I show this new var as the search criteria when the criteria array facet_name is equal to _search and the search is advanced. Which shows a much nicer list of criteria from the advanced search

Image

The line I have uncommented was obviously commented out for a reason. Would this be causing any issues I've yet to realise?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions