diff --git a/templates/node/node--uw-ct-contact--teaser.html.twig b/templates/node/node--uw-ct-contact--teaser.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..0a8d38958e9ca10b23a84d05e555e0538adee008 --- /dev/null +++ b/templates/node/node--uw-ct-contact--teaser.html.twig @@ -0,0 +1,3 @@ +{% include '@components/contact/contact.twig' with { + 'contact': contact, +}%} diff --git a/templates/views/views-view--uw_view_contacts.html.twig b/templates/views/views-view--uw_view_contacts.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..0226ab95e7fa101c229ea36abc18d50b3f3c890d --- /dev/null +++ b/templates/views/views-view--uw_view_contacts.html.twig @@ -0,0 +1,30 @@ +{% + set classes = [ + 'view', + 'view-' ~ id|clean_class, + 'view-id-' ~ id, + 'view-display-id-' ~ display_id, + dom_id ? 'js-view-dom-id-' ~ dom_id, +] +%} + +{% include '@components/view/view--contact/view--contact.twig' with { + 'attributes': attributes, + 'css_name': css_name, + 'css_class': css_class, + 'header': header, + 'footer': footer, + 'rows': rows, + 'empty': empty, + 'pager': pager, + 'exposed': exposed, + 'feed_icons': feed_icons, + 'more': more, + 'title': title, + 'title_prefix': title_prefix, + 'title_suffix': title_suffix, + 'attachment_before': attachment_before, + 'attachment_after': attachment_after, + 'dom_id': dom_id, +} %} + diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index 06136de90606b451072c789fb3e126c8e06eff02..d8fb9b6f3b204a45ec1338cd1313ac6279ab9e81 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -9,6 +9,9 @@ use Drupal\Core\Url; use Drupal\file\Plugin\Field\FieldType\FileFieldItemList; use Drupal\image\Plugin\Field\FieldType\ImageItem; use Drupal\Core\Form\FormStateInterface; +use Drupal\file\Entity\File; +use Drupal\image\Entity\ImageStyle; +use Drupal\media\Entity\Media; /** * @file @@ -356,6 +359,7 @@ function uw_fdsu_theme_resp_preprocess_node(&$variables) { // If on a teaser page get the variables for teaser. if ($variables['view_mode'] == 'teaser') { $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. @@ -368,6 +372,50 @@ 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' && $variables['view_mode'] == 'teaser') { + + // 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(); + + // 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' => $profile ? $profile[0]['uri'] : NULL, + ]; + + // Unset the content variable so that we do not + // get a double print. + unset($variables['content']); + } } /**