]> _ Git - fluidbook-v3.git/commitdiff
Prevent error when no author is set for a post. WIP #3641 @0.25
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 16 Jun 2020 14:03:20 +0000 (14:03 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 16 Jun 2020 14:03:20 +0000 (14:03 +0000)
framework/application/controllers/BlogpostController.php
framework/application/views/helpers/BlogBody.php

index 679577072a2ace1d67690d011e755521b772212e..dcd63bbe614f112045d56aa2e3efbc518a5df2f8 100644 (file)
@@ -33,8 +33,11 @@ class BlogpostController extends CubeIT_Controller_PageController {
         $post = reset($post);
         $post = $post->unserialize();
 
+        // Author details
+        $author = $post->getAuthorModel() ? $post->getAuthorModel()->unserialize() : null;
+
         $this->view->post = $post->unserialize();
-        $this->view->author = $post->getAuthorModel()->unserialize();
+        $this->view->author = $author;
         $this->view->headTitle($post->getTitle(), 'SET');
     }
 
index 7f04901ad6836bf1a5bca5ddc9a766ceddbdf0bf..30fb6af61959d1f24892dcfc1092e440a9f055b6 100644 (file)
@@ -25,18 +25,17 @@ class Fluidbook_View_Helper_BlogBody extends CubeIT_View_Helper_Abstract {
         }
 
         // Author details
-        $photo = $this->imageProcess()->imageProcessGetUrl($this->author->getPhoto(), null, 120, 120);
-        $res .= '<div class="blog-author" itemprop="author" itemscope itemtype="http://schema.org/Person">';
-        $res .= '<div class="blog-author-photo" itemprop="image" style="background-image:url('. $photo .');"></div>';
-        $res .= '<div class="blog-author-details">';
-        $res .= '<h3 class="blog-author-name" itemprop="name">'. $this->author->getName() .'</h3>';
-        $res .= '<p class="blog-author-bio" itemprop="jobTitle">'. $this->author->getBio() .'</p>';
-        $res .= $this->linkEmail($this->author->getEmail(), null, ['class' => 'blog-author-email', 'itemprop' => 'email']);
-        $res .= '</div>'; // .blog-author-details
-//        $res .= '<pre>';
-//        $res .= print_r($this->author, true);
-//        $res .= '</pre>';
-        $res .= '</div>'; // .blog-author
+        if ($this->author) {
+            $photo = $this->imageProcess()->imageProcessGetUrl($this->author->getPhoto(), null, 120, 120);
+            $res .= '<div class="blog-author" itemprop="author" itemscope itemtype="http://schema.org/Person">';
+            $res .= '<div class="blog-author-photo" itemprop="image" style="background-image:url(' . $photo . ');"></div>';
+            $res .= '<div class="blog-author-details">';
+            $res .= '<h3 class="blog-author-name" itemprop="name">' . $this->author->getName() . '</h3>';
+            $res .= '<p class="blog-author-bio" itemprop="jobTitle">' . $this->author->getBio() . '</p>';
+            $res .= $this->linkEmail($this->author->getEmail(), null, ['class' => 'blog-author-email', 'itemprop' => 'email']);
+            $res .= '</div>'; // .blog-author-details
+            $res .= '</div>'; // .blog-author
+        }
 
         $res .= '</div>'; // .blog-post-body
         $res .= '</section>'; // .content-wrapper