Skip to content
Snippets Groups Projects
Commit 9d8fb396 authored by Lily Yan's avatar Lily Yan
Browse files

ISTWCMS-6768 Add code to make sure parent level service category works

parent 293bbebc
No related branches found
No related tags found
2 merge requests!60ISTWCMS-6095 Update maxlength settings for title, text fields and link fields...,!47ISTWCMS-6768 6769 Add taxonomy_term_depth to refactor service list page and service category page
...@@ -215,8 +215,22 @@ function uw_ct_service_views_query_alter( ...@@ -215,8 +215,22 @@ function uw_ct_service_views_query_alter(
$load_entities = FALSE; $load_entities = FALSE;
$child_terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, $parent_tid, $depth, $load_entities); $child_terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, $parent_tid, $depth, $load_entities);
if (!empty($child_terms)) { // Services category view is based on nested service categories.
$query->where[1]['conditions'][2]['value'] = 2; // If passing taxonomy term doesn't include child terms, we should
// remove relationship via service category field and related to it.
if (empty($child_terms)) {
unset($query->fields['node__field_uw_service_category_delta']);
unset($query->fields['node__field_uw_service_category_field_uw_service_category_ta']);
unset($query->fields['taxonomy_term_field_data_node__field_uw_service_category_dep']);
unset($query->fields['taxonomy_term_field_data_node__field_uw_service_category_wei']);
unset($view->storage->getDisplay('services_in_category_page')['display_options']['fields']['field_uw_service_category']);
unset($view->storage->getDisplay('services_in_category_page')['display_options']['style']['options']['grouping'][0]);
unset($view->storage->getDisplay('services_in_category_page')['display_options']['relationships']);
unset($view->storage->getDisplay('services_in_category_page')['display_options']['sorts']['depth_level']);
unset($view->storage->getDisplay('services_in_category_page')['display_options']['sorts']['weight']);
unset($query->where[1]['conditions'][2]);
unset($query->orderby[0]);
unset($query->orderby[1]);
} }
} }
} }
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