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

ISTWCMS-4704: updating to get only nodes or teasers or both in preprocess and...

ISTWCMS-4704: updating to get only nodes or teasers or both in preprocess and removing special code for contacts and using default code
parent e1beae19
No related branches found
No related tags found
1 merge request!34ISTWCMS-4847: adding preprocess to main content area to add classes for 404...
......@@ -347,23 +347,37 @@ function uw_fdsu_theme_resp_preprocess_node(&$variables) {
'uw_ct_news_item',
'uw_ct_web_page',
'uw_ct_catalog_item',
'uw_ct_contact',
];
// Teaser to be preprocessed.
$teasers_to_preprocess = [
'uw_ct_blog',
'uw_ct_event',
'uw_ct_news_item',
'uw_ct_web_page',
'uw_ct_catalog_item',
'uw_ct_contact',
];
// If there is a node that needs preprocessing,
// set the appropriate variables.
if (in_array($variables['node']->getType(), $nodes_to_preprocess)) {
if (in_array($variables['node']->getType(), $nodes_to_preprocess) ||
in_array($variables['node']->getType(), $teasers_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') {
if ($variables['view_mode'] == 'teaser' &&
in_array($variables['node']->getType(), $teasers_to_preprocess)) {
$variables['teaser'] = $uwService->uwGetNodeContent($variables['node'], 'teaser', 'all');
$variables['rep_date'] = $variables['content']['field_uw_event_date'];
}
// If on a node page get the variables for now.
if ($variables['view_mode'] == 'full') {
if ($variables['view_mode'] == 'full' &&
in_array($variables['node']->getType(), $nodes_to_preprocess)) {
$variables['node_data'] = $uwService->uwGetNodeContent($variables['node'], 'full', 'all');
$variables['node_data']['content'] = $variables['content'];
}
......@@ -372,78 +386,6 @@ function uw_fdsu_theme_resp_preprocess_node(&$variables) {
// a second print of all the content.
unset($variables['content']);
}
if ($variables['node']->getType() == 'uw_ct_contact') {
// The UW service object.
$uwService = \Drupal::service('uw_cfg_common.uw_service');
// Get the node.
$node = $variables['node'];
// Get the media id.
$mid = $node->field_uw_ct_contact_image->getValue();
// If there is an image, process it.
if ($mid) {
// Load in the media item.
$media = Media::load($mid[0]['target_id']);
// Get the file id from the media object.
$fid = $media->getSource()->getSourceFieldValue($media);
// If there is a file id, then get the uri,
// using the thumbnail image style.
if ($fid) {
$file = File::load($fid);
$image_uri = ImageStyle::load('thumbnail')->buildUrl($file->getFileUri());
}
}
// Get the profile.
$profile = $node->field_uw_ct_contact_link_profile->getValue();
// Get personal website or cv.
$personal_website = $node->field_uw_ct_contact_link_persona->getValue();
// Get the additional info field.
$additional_info = $node->field_uw_ct_contact_info->getValue();
// If there is additional info, setup render array.
if ($additional_info) {
$additional_info = [
'#type' => 'processed_text',
'#text' => $additional_info[0]['value'],
'#format' => $additional_info[0]['format'],
];
}
// Setup the variables for contact.
$variables['contact'] = [
'title' => $node->getTitle(),
'position' => $node->field_uw_ct_contact_title->value,
'image' => isset($image_uri) ? $image_uri : NULL,
'email' => $node->field_uw_ct_contact_email->value,
'phone' => $node->field_uw_ct_contact_phone->value,
'location' => $node->field_uw_ct_contact_location->value,
'link_profile' => [
'uri' => $profile ? $profile[0]['uri'] : NULL,
'title' => $profile ? $profile[0]['title'] : NULL,
],
'contact_for' => $node->field_uw_ct_contact_contact_for->value,
'personal_website' => [
'uri' => $personal_website ? $personal_website[0]['uri'] : NULL,
'title' => $personal_website ? $personal_website[0]['title'] : NULL,
],
'groups' => $uwService->uwGetTermsFromEntityField($node->field_uw_ct_contact_group, 'tags'),
'additional_info' => $additional_info ? $additional_info : NULL,
];
// Unset the content variable so that we do not
// get a double print.
unset($variables['content']);
}
}
/**
......@@ -525,6 +467,7 @@ function uw_fdsu_theme_resp_preprocess_container(&$variables) {
'uw_ct_blog',
'uw_ct_news_item',
'uw_ct_event',
'uw_ct_contact',
];
// Get the node object.
......@@ -545,6 +488,7 @@ function uw_fdsu_theme_resp_preprocess_container(&$variables) {
if ($node) {
$variables['header_data'] = $uwService->uwGetNodeContent($node, 'teaser', 'header');
$variables['footer_data'] = $uwService->uwGetNodeContent($node, 'teaser', 'footer');
$test = '';
}
}
}
......
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