Skip to content
Snippets Groups Projects
Commit f2aea8bf authored by Eric Bremner's avatar Eric Bremner Committed by Kevin Paxman
Browse files

ISTWCMS-6944: Fix the label for catalogs when there are no catalogs

parent ac5fd5a0
No related branches found
No related tags found
1 merge request!240ISTWCMS-6944: add code for search label to services search block
......@@ -133,7 +133,7 @@ class UwCblCatalogSearch extends BlockBase implements ContainerFactoryPluginInte
// If there is no block title, then set the label so that
// the template will know to place a visually hidden one.
if (!$this->configuration['label_display']) {
if (!$this->configuration['label_display'] && $catalog_available_flag) {
$catalog_search['label'] = $this->t('Catalog search');
}
......
......@@ -639,8 +639,25 @@ function uw_custom_blocks_preprocess_block(&$variables) {
// If this is a search block add the label stuff to the variables.
if (in_array($variables['plugin_id'], $search_blocks)) {
$variables['add_label_flag'] = TRUE;
$variables['label_for'] = 'edit-search-input-' . $variables['configuration']['uuid'];
// If this is a catalog, then ensure there are terms.
if (isset($variables['configuration']['catalog'])) {
// Load the taxonomy term.
$term = \Drupal::service('entity_type.manager')
->getStorage('taxonomy_term')
->load($variables['configuration']['catalog']);
// If the term is null, set the flag.
if ($term) {
$variables['add_label_flag'] = TRUE;
$variables['label_for'] = 'edit-search-input-' . $variables['configuration']['uuid'];
}
}
else {
$variables['add_label_flag'] = TRUE;
$variables['label_for'] = 'edit-search-input-' . $variables['configuration']['uuid'];
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment