diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index 0c6e727fa5f13c3c8dedd8555b3eff25d5411b4d..abc415e0b2adc212fc35b69a6c1b5b63d74682da 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -330,6 +330,44 @@ function _uw_fdsu_theme_resp_get_image_info(FileFieldItemList $field) { } } +/** + * Implements hook_preprocess_node(). + * + * Set variables for node and teaser. + */ +function uw_fdsu_theme_resp_preprocess_node(&$variables) { + + // The types of nodes the need preprocessing. + $nodes_to_preprocess = [ + 'uw_ct_blog', + 'uw_ct_event', + 'uw_ct_news_item', + ]; + + // If there is a node that needs preprocessing, + // set the appropriate variables. + if (in_array($variables['node']->getType(), $nodes_to_preprocess)) { + + // The UW service object. + $uwService = \Drupal::service('uw_cfg_common.uw_service'); + + // If on a teaser page get the variables for teaser. + if ($variables['view_mode'] == 'teaser') { + $variables['teaser'] = $uwService->uwGetNodeContent($variables['node'], 'teaser', 'all'); + } + + // If on a node page get the variables for now. + if ($variables['view_mode'] == 'full') { + $variables['node_data'] = $uwService->uwGetNodeContent($variables['node'], 'full', 'all'); + $variables['node_data']['content'] = $variables['content']; + } + + // Unset the content variable, so that we do not get + // a second print of all the content. + unset($variables['content']); + } +} + /** * Implements hook_preprocess_block(). *