Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $category = array('Your Category Id' => array('Price','Your attribute title'));
- <?php $currentCategory = Mage::registry('current_category')->getId(); ?>
- <?php foreach ($_filters as $_filter): ?>
- <?php if($_filter->getItemsCount()): ?>
- <?php if(in_array($_filter->getName(),$category[$currentCategory])){
- continue;
- } ?>
- <dt><?php echo $this->__($_filter->getName()) ?></dt>
- <dd><?php echo $_filter->getHtml() ?></dd>
- <?php endif; ?>
- <?php endforeach; ?>
- if (Mage::app()->getFrontController()->getAction()->getFullActionName() == 'catalogsearch_result_index') {
- // The current page is the search page
- }
- protected function _prepareLayout()
- {
- $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)
- ->setLayer($this->getLayer());
- $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
- ->setLayer($this->getLayer())
- ->init();
- $this->setChild('layer_state', $stateBlock);
- $this->setChild('category_filter', $categoryBlock);
- $filterableAttributes = $this->_getFilterableAttributes();
- foreach ($filterableAttributes as $attribute) {
- if (
- Mage::registry('current_category')->getId() == 19
- && in_array($attribute->getAttributeCode(), array('style'))
- ) {
- continue;
- }
- if ($attribute->getAttributeCode() == 'price') {
- $filterBlockName = $this->_priceFilterBlockName;
- } elseif ($attribute->getBackendType() == 'decimal') {
- $filterBlockName = $this->_decimalFilterBlockName;
- } else {
- $filterBlockName = $this->_attributeFilterBlockName;
- }
- $this->setChild($attribute->getAttributeCode() . '_filter',
- $this->getLayout()->createBlock($filterBlockName)
- ->setLayer($this->getLayer())
- ->setAttributeModel($attribute)
- ->init());
- }
- $this->getLayer()->apply();
- return parent::_prepareLayout();
- }
- public function getFilters()
- {
- $filters = array();
- if ($categoryFilter = $this->_getCategoryFilter()) {
- $filters[] = $categoryFilter;
- }
- $filterableAttributes = $this->_getFilterableAttributes();
- foreach ($filterableAttributes as $attribute) {
- $filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
- }
- foreach ($filters as $filter) {
- if ($filter !== false) {
- $result[] = $filter;
- }
- }
- return $result;
- }
- if (
- Mage::registry('current_category')->getId() == 19
- && in_array($attribute->getAttributeCode(), array('style'))
- ) {
- continue;
- }
- foreach ($filters as $filter) {
- if ($filter !== false) {
- $result[] = $filter;
- }
- }
- return $result;
- <?php
- /**
- * Category layered navigation
- *
- * @see Mage_Catalog_Block_Layer_View
- */
- ?>
- <?php $pageIdentifier = Mage::app()->getFrontController()->getAction()->getFullActionName() ?>
- <?php if ($pageIdentifier!='catalogsearch_result_index'): ?>
- <?php $currentCategory = Mage::registry('current_category')->getId() ?>
- <?php $filterCategory['63'] = array('Price') ?>
- <?php $filterCategory['89'] = array('Manufacturer') ?>
- <?php endif; ?>
- <?php if($this->canShowBlock()): ?>
- <div class="block block-layered-nav">
- <div class="block-title">
- <strong><span><?php echo $this->__('Shop By') ?></span></strong>
- </div>
- <div class="block-content">
- <?php echo $this->getStateHtml() ?>
- <?php if ($this->getLayer()->getState()->getFilters()): ?>
- <div class="actions"><a href="<?php echo $this->getClearUrl() ?>"><?php echo $this->__('Clear All') ?></a></div>
- <?php endif; ?>
- <?php if($this->canShowOptions()): ?>
- <p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>
- <dl id="narrow-by-list">
- <?php $_filters = $this->getFilters() ?>
- <?php foreach ($_filters as $_filter): ?>
- <?php if($_filter->getItemsCount()): ?>
- <?php if(in_array($_filter->getName(),$filterCategory[$currentCategory])) continue ?>
- <dt><?php echo $this->__($_filter->getName()) ?></dt>
- <dd><?php echo $_filter->getHtml() ?></dd>
- <?php endif; ?>
- <?php endforeach; ?>
- </dl>
- <script type="text/javascript">decorateDataList('narrow-by-list') </script>
- <?php endif; ?>
- </div>
- </div>
- <?php endif; ?>
- public function hideAttributes($attributeCodes)
- {
- $attributeCodes = array_map('trim', explode(',', $attributeCodes));
- $this->setData('hide_attributes', $attributeCodes);
- }
- public function getFilters()
- {
- $filters = array();
- if ($categoryFilter = $this->_getCategoryFilter()) {
- $filters[] = $categoryFilter;
- }
- $filterableAttributes = $this->_getFilterableAttributes();
- # added line
- $hiddenAttributes = $this->getHideAttributes();
- foreach ($filterableAttributes as $attribute) {
- # added line
- if (!$hiddenAttributes || (is_array($hiddenAttributes) && !in_array($attribute->getAttributeCode(), $hiddenAttributes))) { # added
- $filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
- }
- }
- return $filters;
- }
- <reference name="catalog.leftnav">
- <action method="hideAttributes"><code>price,manufacturer</code></action>
- </reference>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement