Skip to content
Snippets Groups Projects
Commit 979ff8af authored by Eric Bremner's avatar Eric Bremner Committed by Eric Bremner
Browse files

ISTWCMS-4704: centralizing preprocess node function for full and teaser nodes

parent 4a5476aa
No related branches found
No related tags found
1 merge request!34ISTWCMS-4847: adding preprocess to main content area to add classes for 404...
......@@ -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().
*
......
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