bondjimbond / islandora_metadata_extras

Islandora utility module that provides some options for customizing metadata display and generation.
GNU General Public License v3.0
6 stars 2 forks source link

Replace facet labels #32

Closed bondjimbond closed 4 years ago

bondjimbond commented 4 years ago

Handles issue #20

Now that https://github.com/Islandora/islandora_solr_search/pull/370 has been merged, this will work.

What does this Pull Request do?

Using the new features in hook_islandora_solr_facet_bucket_classes_alter() to modify the facet label, allows you to define a string from a search facet and replace it with an alternative.

How should this be tested?

Interested parties

@mjordan

mjordan commented 4 years ago

I'm probably not doing something right. Here's my facet cofig:

config

and here's my facet page:

mimefacets

The values are not being replaced. Any suggestions?

bondjimbond commented 4 years ago

Do you have the latest commit to Islandora Solr?

mjordan commented 4 years ago

Yes, I pulled in the most recent updates yesterday.

I didn't test exactly as you describe, I created a facet browse page. But, that shouldn't matter, AFAIK, facets in search results are the same as facets in a facet browse page. Do you think that matters?

bondjimbond commented 4 years ago

No idea... worth testing it the way I suggested, though, and see if that makes a difference.

mjordan commented 4 years ago

I will. Does using a facet page work for you?

bondjimbond commented 4 years ago

Hmm, looks like no - only the facets sidebar. I never tried this with facet pages... they must work differently.

bondjimbond commented 4 years ago

I wonder if somehow the hook doesn't fire on facet pages?

mjordan commented 4 years ago

I'm not sure, but if hook_islandora_solr_facet_bucket_classes_alter() is only be fired in includes/blocks.inc, that would explain my test results:

vagrant@islandora:/var/www/drupal/sites/all/modules/islandora_solr_search$ grep -r drupal_alter *
includes/blocks.inc:      drupal_alter($hooks, $attributes, $_islandora_solr_queryclass);
includes/query_processor.inc:    drupal_alter('islandora_solr_query', $this);
includes/query_processor.inc:                drupal_alter($hook_list, $object_results[$object_index], $this);
includes/query_processor.inc:          drupal_alter('islandora_solr_results', $object_results, $this);
includes/results.inc:      drupal_alter($hooks, $attributes, $islandora_solr_query);
includes/results.inc:        drupal_alter($hooks, $attributes, $islandora_solr_query);
includes/results.inc:    drupal_alter('islandora_breadcrumbs', $breadcrumb, $context);
includes/results.inc:      drupal_alter($hooks, $attributes, $islandora_solr_query);
islandora_solr_config/includes/rss_results.inc:      drupal_alter('islandora_solr_search_rss_item', $item, $doc);
islandora_solr_config/includes/rss_results.inc:      drupal_alter('islandora_solr_config_rss_item_post_render', $rendered_item, $doc);
islandora_solr_config/includes/rss_results.inc:    drupal_alter('islandora_solr_config_rss_root_element_attributes', $rss_attributes, $channel, $items);

But, I can't find the menu item for facet pages (/browse/xxxx) so I don't know where else to look.

mjordan commented 4 years ago

How does one create a facet block? All I found in the documentation wiki was "This module provides a block named "Islandora Solr facet pages" that can be configured in Block settings (Administration » Structure » Blocks). It contains a list of links to all configured facet pages." When I enable a "Islandora Solr facet pages' block", I don't see a list of facet pages:

foo

bondjimbond commented 4 years ago

How does one create a facet block? All I found in the documentation wiki was "This module provides a block named "Islandora Solr facet pages" that can be configured in Block settings (Administration » Structure » Blocks). It contains a list of links to all configured facet pages." When I enable a "Islandora Solr facet pages' block", I don't see a list of facet pages

Enable the block, stick it in your sidebar, and you'll get links to any facet pages that exist.

Screen Shot 2020-01-17 at 9 30 24 AM

I'm not sure, but if hook_islandora_solr_facet_bucket_classes_alter() is only be fired in includes/blocks.inc, that would explain my test results

I can note in the admin form that this will only work in search facets and not facet pages, if that helps?

bondjimbond commented 4 years ago

@mjordan Any further thoughts on this? Do you want some text in the admin form about facet pages? Is it otherwise good to go?

mjordan commented 4 years ago

@bondjimbond yes, some text that explains that would be useful. Then I'll merge.

mjordan commented 4 years ago

Also, would you mind adding a bullet point about this new feature in the README?

bondjimbond commented 4 years ago

@mjordan Updated. Let me know if the wording still needs adjustment.

mjordan commented 4 years ago

Looks good. Thanks!

bondjimbond commented 4 years ago

Noted an issue here. Every time there's a search, this appears in the logs:

Notice: Undefined offset: 1 in islandora_metadata_extras_facet_convert() (line 68 of /var/www/html/drupal7/sites/all/modules/islandora_metadata_extras/includes/utilities.inc).

This happens only in my production site; not in Vagrant.

Is it possible there might be an out of date module creating this conflict? Do you get similar results?