Skip to content

Commit

Permalink
Merge pull request #17 from thelia-modules/feature/homepage
Browse files Browse the repository at this point in the history
update page template hierarchy
  • Loading branch information
zawaze committed Mar 14, 2024
2 parents 5e6b57c + 90cef0b commit c92ec07
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.2.1</version>
<version>1.2.2</version>
<authors>
<author>
<name>Damien Foulhoux</name>
Expand Down
5 changes: 2 additions & 3 deletions EventListener/KernelViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ public function onKernelView(ViewEvent $event)
if ($view === "index") {
$page = PageQuery::create()
->filterByIsHome(1)
->usePageTypeQuery('', Criteria::INNER_JOIN)
->endUse()
->findOne();
}



if (!$page) {
return;
}
Expand Down
12 changes: 11 additions & 1 deletion Service/PageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ public function __construct(SmartyParser $parser)
}
public function getPageTemplateName(PageModel $page, bool $readCode = true)
{

if ($page->isHome()) {
$templateName = 'page-home';
if ($this->parser->templateExists($templateName.'.html')) {
return $templateName;
}
}


if ($readCode) {
$codeTemplateName = 'page-' . $page->getCode();
if ($this->parser->templateExists($codeTemplateName.'.html')) {
Expand All @@ -37,14 +46,15 @@ public function getPageTemplateName(PageModel $page, bool $readCode = true)
return $typeTemplateName;
}
}


$parent = $page->getParent();

if (null === $parent) {
return null;
}

return $this->getPageTemplateName($parent, false);
return $this->getPageTemplateName($parent, true);
}


Expand Down

0 comments on commit c92ec07

Please sign in to comment.