Skip to content

Commit

Permalink
Merge pull request #50 from MayMeow/dev/fix-front-page
Browse files Browse the repository at this point in the history
FIXED front page
  • Loading branch information
MayMeow authored Oct 16, 2023
2 parents d325c18 + 4ff4a00 commit e429fbf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/Controller/ArticlesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function index(ArticlesManagerServiceInterface $articlesManager, BlogsMan
$homePage = $articlesManager->getHomePageContent($this->request);

$this->paginate = [
'contain' => ['Users', 'Blogs'],
'order' => ['Articles.created' => 'DESC'],
'limit' => 10,
];
Expand Down
3 changes: 2 additions & 1 deletion src/Services/ArticlesManagerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ public function getAll(ServerRequest $request, AppController $controller, bool $
{
$blog = $this->articles->Blogs->find()->where(['Blogs.domain' => $request->getUri()->getHost()])->first();

// if blog exists find only blog's article otherwise find show all
if ($blog) {
$articles = $this->articles->find()->contain(['Users', 'Blogs'])->where([
'Articles.blog_id' => $blog->id,
'Articles.article_type' => $articleType->value,
]);
} else {
$articles = $this->articles->find()->where([
$articles = $this->articles->find()->contain(['Users', 'Blogs'])->where([
'Articles.article_type' => $articleType->value,
]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/View/Helper/ArticlesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function getBlogId(ServerRequest $request): ?int
}

public function isInCurrentBlog(Article $article): bool
{
return $this->getBlogId($this->getView()->getRequest()) == $article->blog->id ? true : false;
{
return $this->getBlogId($this->getView()->getRequest()) == $article->blog?->id ? true : false;
}
}

0 comments on commit e429fbf

Please sign in to comment.