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

ISTWCMS-4704: adding templates and functions for contacts view

parent af231d0b
No related branches found
No related tags found
1 merge request!34ISTWCMS-4847: adding preprocess to main content area to add classes for 404...
{% include '@components/contact/contact.twig' with {
'contact': contact,
}%}
{%
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,
} %}
......@@ -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']);
}
}
/**
......
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