This repository has been archived by the owner on Oct 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add link renderer and item renderer for link
- Loading branch information
Showing
9 changed files
with
156 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
Block/LayeredNavigation/RenderLayered/LinkRenderer/ItemRenderer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/** | ||
* Tweakwise & Emico (https://www.tweakwise.com/ & https://www.emico.nl/) - All Rights Reserved | ||
* | ||
* @copyright Copyright (c) 2017-2017 Tweakwise.com B.V. (https://www.tweakwise.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
namespace Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\LinkRenderer; | ||
|
||
use Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\LinkRenderer; | ||
use Emico\Tweakwise\Model\Catalog\Layer\Filter\Item; | ||
|
||
/** | ||
* Class ItemRenderer | ||
* @package Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\LinkRenderer | ||
*/ | ||
class ItemRenderer extends LinkRenderer | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected $_template = 'Emico_Tweakwise::product/layered/link/item.phtml'; | ||
|
||
/** | ||
* @var Item | ||
*/ | ||
protected $item; | ||
|
||
/** | ||
* @return Item | ||
*/ | ||
public function getItem() | ||
{ | ||
return $this->item; | ||
} | ||
|
||
/** | ||
* @param Item $item | ||
* @return $this | ||
*/ | ||
public function setItem(Item $item) | ||
{ | ||
$this->item = $item; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function hasChildren() | ||
{ | ||
return $this->item->hasChildren(); | ||
} | ||
|
||
/** | ||
* @return Item[] | ||
*/ | ||
public function getChildren() | ||
{ | ||
return $this->item->getChildren(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Tweakwise & Emico (https://www.tweakwise.com/ & https://www.emico.nl/) - All Rights Reserved | ||
* | ||
* @copyright Copyright (c) 2017-2017 Tweakwise.com B.V. (https://www.tweakwise.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
use Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\TreeRenderer; | ||
|
||
/** @var $block \Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\LinkRenderer */ | ||
?> | ||
<ol class="items"> | ||
<?php foreach ($block->getItems() as $item): ?> | ||
<?=$block->renderLinkItem($item)?> | ||
<?php endforeach; ?> | ||
</ol> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Tweakwise & Emico (https://www.tweakwise.com/ & https://www.emico.nl/) - All Rights Reserved | ||
* | ||
* @copyright Copyright (c) 2017-2017 Tweakwise.com B.V. (https://www.tweakwise.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
use Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\LinkRenderer\ItemRenderer; | ||
|
||
/** @var $block ItemRenderer */ | ||
$item = $block->getItem(); | ||
?> | ||
<li class="item"> | ||
<a href="<?=$block->escapeUrl($item->getUrl())?>"> | ||
<?=$block->getItemPrefix()?> | ||
<?=$block->escapeHtml($item->getLabel())?> | ||
<?=$block->getItemPostfix()?> | ||
|
||
<?php if ($block->shouldDisplayProductCountOnLayer()): ?> | ||
<span class="count"> | ||
<?=htmlentities($item->getCount())?> | ||
<span class="filter-count-label"> | ||
<?php if ($item->getCount() == 1):?> | ||
<?=__('item')?> | ||
<?php else:?> | ||
<?=__('items')?> | ||
<?php endif;?> | ||
</span> | ||
</span> | ||
<?php endif; ?> | ||
</a> | ||
|
||
<?php if ($block->hasChildren()): ?> | ||
<ol class="items child-items"> | ||
<?php foreach ($item->getChildren() as $child): ?> | ||
<?=$block->renderTreeItem($child)?> | ||
<?php endforeach; ?> | ||
</ol> | ||
<?php endif; ?> | ||
</li> |