diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index d779347..c6f99e3 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -131,19 +131,21 @@ class MainController extends AppController { return $this->redirect('/'); } - $json = json_decode($claim->Stream->Stream); - if (isset($json->metadata->license)) { - $claim->License = $json->metadata->license; - } - if (isset($json->metadata->licenseUrl)) { - $claim->LicenseUrl = $json->metadata->licenseUrl; + if (isset($claim->Stream)) { + $json = json_decode($claim->Stream->Stream); + if (isset($json->metadata->license)) { + $claim->License = $json->metadata->license; + } + if (isset($json->metadata->licenseUrl)) { + $claim->LicenseUrl = $json->metadata->licenseUrl; + } } $moreClaims = []; - if (isset($claim->Publisher)) { + if (isset($claim->Publisher) || $claim->ClaimType == 1) { // find more claims for the publisher $moreClaims = $this->Claims->find()->contain(['Stream', 'Publisher' => ['fields' => ['Name']]])-> - where(['Claims.ClaimType' => 2, 'Claims.Id <>' => $claim->Id, 'Claims.PublisherId' => $claim->Publisher->ClaimId])-> + where(['Claims.ClaimType' => 2, 'Claims.Id <>' => $claim->Id, 'Claims.PublisherId' => isset($claim->Publisher) ? $claim->Publisher->ClaimId : $claim->ClaimId])-> limit(9)->order(['RAND()' => 'DESC'])->toArray(); for ($i = 0; $i < count($moreClaims); $i++) { if (isset($moreClaims[$i]->Stream)) { diff --git a/src/Template/Main/claims.ctp b/src/Template/Main/claims.ctp index b5f9fc8..6138ba5 100644 --- a/src/Template/Main/claims.ctp +++ b/src/Template/Main/claims.ctp @@ -138,7 +138,7 @@ if (strlen(trim($desc)) == 0) { 0): ?>