Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Backend/Modules/Blog/Installer/Data/locale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,15 @@
<translation language="pl"><![CDATA[Można przesyłać tylko pliki XML.]]></translation>
</item>
</Blog>
<Pages>
<item type="label" name="Detail">
<translation language="nl"><![CDATA[detail]]></translation>
<translation language="en"><![CDATA[detail]]></translation>
<translation language="fr"><![CDATA[détail]]></translation>
<translation language="de"><![CDATA[detail]]></translation>
<translation language="es"><![CDATA[detalle]]></translation>
</item>
</Pages>
<Core>
<item type="label" name="RelatedArticles">
<translation language="nl"><![CDATA[gerelateerde artikelen]]></translation>
Expand Down
19 changes: 15 additions & 4 deletions src/Backend/Modules/Blog/Installer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Installer extends ModuleInstaller
/** @var int */
private $blogBlockId;

/** @var int */
private $blogBlockDetailId;

public function install(): void
{
$this->addModule('Blog');
Expand Down Expand Up @@ -101,6 +104,7 @@ private function configureBackendWidgets(): void
private function configureFrontendExtras(): void
{
$this->blogBlockId = $this->insertExtra($this->getModule(), ModuleExtraType::block(), 'Blog');
$this->blogBlockDetailId = $this->insertExtra($this->getModule(), ModuleExtraType::block(), 'Detail', 'Detail');
$this->insertExtra($this->getModule(), ModuleExtraType::widget(), 'Archive', 'Archive');
$this->insertExtra($this->getModule(), ModuleExtraType::widget(), 'Categories', 'Categories');
$this->insertExtra($this->getModule(), ModuleExtraType::widget(), 'RecentArticlesFull', 'RecentArticlesFull');
Expand Down Expand Up @@ -131,13 +135,20 @@ private function configureFrontendPages(): void
$this->setSetting($this->getModule(), 'rss_description_' . $language, '');

// check if a page for blog already exists in this language
if (!$this->hasPageWithBlogBlock($language)) {
$this->insertPage(
if (!$this->hasPageWithBlogBlock($language, $this->blogBlockId)) {
$indexId = $this->insertPage(
['title' => 'Blog', 'language' => $language],
null,
['extra_id' => $this->blogBlockId, 'position' => 'main'],
['extra_id' => $searchId, 'position' => 'top']
);
if (!$this->hasPageWithBlogBlock($language, $this->blogBlockDetailId)) {
$this->insertPage(
['title' => 'Detail', 'language' => $language, 'parent_id' => $indexId],
null,
['extra_id' => $this->blogBlockDetailId, 'position' => 'main'],
);
}
}

if ($this->installExample()) {
Expand Down Expand Up @@ -182,7 +193,7 @@ private function getSearchWidgetId(): int
);
}

private function hasPageWithBlogBlock(string $language): bool
private function hasPageWithBlogBlock(string $language, int $blockId): bool
{
// @todo: Replace with a PageRepository method when it exists.
return (bool) $this->getDatabase()->getVar(
Expand All @@ -191,7 +202,7 @@ private function hasPageWithBlogBlock(string $language): bool
INNER JOIN pages_blocks AS b ON b.revision_id = p.revision_id
WHERE b.extra_id = ? AND p.language = ?
LIMIT 1',
[$this->blogBlockId, $language]
[$blockId, $language]
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Frontend/Modules/Blog/Actions/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ protected function setMeta(Meta $meta): void

private function getBlogPost(): array
{
if ($this->url->getParameter(1) === null) {
if ($this->url->getParameter(0) === null) {
throw new NotFoundHttpException();
}

if ($this->url->getParameter('revision', 'int') === null) {
return $this->completeBlogPost(FrontendBlogModel::get($this->url->getParameter(1)));
return $this->completeBlogPost(FrontendBlogModel::get($this->url->getParameter(0)));
}

return $this->completeBlogPost(
FrontendBlogModel::getRevision(
$this->url->getParameter(1),
$this->url->getParameter(0),
$this->url->getParameter('revision', 'int')
)
);
Expand Down
Loading