diff --git a/src/Service/UwNodeContent.php b/src/Service/UwNodeContent.php index 596fcb327f9bbe7a702f2eeb822fae8a6b4f421a..383d485e42f7b4e1874fee9a615e67e2a7c1deed 100644 --- a/src/Service/UwNodeContent.php +++ b/src/Service/UwNodeContent.php @@ -54,11 +54,11 @@ class UwNodeContent { switch ($node->getType()) { case 'uw_ct_blog': - $content_data = $this->getBlogContent($node_flags); + $content_data = $this->getBlogContent($node_flags, $view_mode); break; case 'uw_ct_event': - $content_data = $this->getEventContent($node_flags); + $content_data = $this->getEventContent($node_flags, $view_mode); break; case 'uw_ct_expand_collapse_group': @@ -66,7 +66,7 @@ class UwNodeContent { break; case 'uw_ct_news_item': - $content_data = $this->getNewsContent($node_flags); + $content_data = $this->getNewsContent($node_flags, $view_mode); break; case 'uw_ct_web_page': @@ -237,21 +237,27 @@ class UwNodeContent { * * @param array $node_flags * The flags for the node. + * @param string $view_mode + * The view mode of the node. * * @return array * Array of content to get from the node. */ - public function getBlogContent(array $node_flags): array { + public function getBlogContent(array $node_flags, string $view_mode): array { // Get the content data. $content_data = $this->setupContentData($node_flags); // Setup the header content. if ($node_flags['get_header']) { - $content_data['header']['date'] = $this->addToContentData('date', 'field_uw_blog_date'); - $content_data['header']['author'] = $this->addToContentData('author', 'field_author'); + if ($view_mode == 'teaser') { + $content_data['header']['date'] = $this->addToContentData('date', 'field_uw_blog_date'); + } + else { + $content_data['header']['date'] = $this->addToContentData('date', 'field_uw_blog_date'); + $content_data['header']['author'] = $this->addToContentData('author', 'field_author'); + } } - // Get the media. if ($node_flags['get_media']) { $content_data['media'] = $this->addToContentData('media', NULL); @@ -382,18 +388,26 @@ class UwNodeContent { * * @param array $node_flags * The flags for the node. + * @param string $view_mode + * The view mode of the node. * * @return array * Array of content to get from the node. */ - public function getNewsContent(array $node_flags): array { + public function getNewsContent(array $node_flags, string $view_mode): array { // Get the content data. $content_data = $this->setupContentData($node_flags); // Setup the header content. if ($node_flags['get_header']) { - $content_data['header']['date'] = $this->addToContentData('date', 'field_uw_news_date'); + if ($view_mode == 'teaser') { + $content_data['header']['date'] = $this->addToContentData('date', 'field_uw_news_date'); + } + else { + $content_data['header']['date'] = $this->addToContentData('date', 'field_uw_news_date'); + $content_data['header']['author'] = $this->addToContentData('author', 'field_author'); + } } // Get the media. diff --git a/src/Service/UwNodeFieldValue.php b/src/Service/UwNodeFieldValue.php index 21c749c19db2ab66d2b795c2153666d33c5909f2..0a9e12e091c1587d3575e48bc1998fbfa8e1d6f4 100644 --- a/src/Service/UwNodeFieldValue.php +++ b/src/Service/UwNodeFieldValue.php @@ -650,13 +650,9 @@ class UwNodeFieldValue { */ public function getAuthor(Node $node): array { - // Get the author field from the node, if there is - // no author specified the value will be NULL. - $author_name = $node->field_author->value; - // If there is no author in the field, get the owner // of the blog post. - if (!$author_name) { + if (!$node->field_author) { // Set the author to the person who made blog. $author = [ @@ -670,7 +666,8 @@ class UwNodeFieldValue { // Get the link field from the node. $link = $node->field_uw_author_link->getValue(); - $author['name'] = $author_name; + // Get the auther name from the node. + $author['name'] = $node->field_author->value; if (!empty($link)) { $author['link'] = $link[0]['uri'];