Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Add required frontend files and modify required logic to present link…
Browse files Browse the repository at this point in the history
… view
  • Loading branch information
Hnto committed Aug 4, 2021
1 parent 7233c4d commit 4ab1b42
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public function hasChildren()
*/
public function getChildren()
{
// When rendering link items we need to remove everything after the first nesting
// because "link view (linkweergave)" has a max of 1 nesting
foreach ($this->item->getChildren() as $child) {
$child->setChildren([]);
}
return $this->item->getChildren();
}
}
5 changes: 1 addition & 4 deletions Block/Navigation/FilterRenderer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public function aroundRender(FilterRenderer $subject, Closure $proceed, FilterIn
$facet = $filter->getFacet();
$settings = $facet->getFacetSettings();
$renderType = $settings->getSelectionType();

if ($this->config->getUseDefaultLinkRenderer() && in_array($renderType, $this->defaultAllowedRenderTypes)) {
return $proceed($filter);
}
Expand All @@ -121,10 +122,6 @@ public function aroundRender(FilterRenderer $subject, Closure $proceed, FilterIn
*/
protected function getBlockType(SettingsType $settings)
{
if ($settings->getSource() === SettingsType::SOURCE_CATEGORY) {
return TreeRenderer::class;
}

$renderType = $settings->getSelectionType();
return $this->blockTypes[$renderType] ?? DefaultRenderer::class;
}
Expand Down
2 changes: 1 addition & 1 deletion Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function getHideSingleOptions(Store $store = null)
*/
public function getUseDefaultLinkRenderer(Store $store = null)
{
return (bool)$this->getStoreConfig('tweakwise/layered/default_link_renderer', $store);
return (bool) $this->getStoreConfig('tweakwise/layered/default_link_renderer', $store);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/templates/product/layered/link.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\TreeRenderer;

/** @var $block \Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\LinkRenderer */
?>
<ol class="items">
<ol class="items link-attribute">
<?php foreach ($block->getItems() as $item): ?>
<?=$block->renderLinkItem($item)?>
<?php endforeach; ?>
Expand Down
5 changes: 3 additions & 2 deletions view/frontend/templates/product/layered/link/item.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\LinkRenderer\ItemRende
/** @var $block ItemRenderer */
$item = $block->getItem();
?>

<li class="item">
<a href="<?=$block->escapeUrl($item->getUrl())?>">
<?=$block->getItemPrefix()?>
Expand All @@ -32,8 +33,8 @@ $item = $block->getItem();

<?php if ($block->hasChildren()): ?>
<ol class="items child-items">
<?php foreach ($item->getChildren() as $child): ?>
<?=$block->renderTreeItem($child)?>
<?php foreach ($block->getChildren() as $child): ?>
<?=$block->renderLinkItem($child)?>
<?php endforeach; ?>
</ol>
<?php endif; ?>
Expand Down
3 changes: 3 additions & 0 deletions view/frontend/web/css/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
margin-left: 15px;
}

.link-attribute .child-items {
margin-left: 15px;
}

.search-autocomplete {
ul {
Expand Down

0 comments on commit 4ab1b42

Please sign in to comment.