Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

can we show/hide a sidebar depending on if it’s full/empty
 
DnD Thomas
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2008-09-26
 

hi everyone

maybe the title of the topic isn’t clear,

i wanna know if i can hide my compare sidebar when there is no item in it , and show it when there is item to compare ?
as i know from magento , i don’t think i can do that with the xml files…

maybe someone would have the kindness to give me a hand on that !!

thx for reading my post.

cya

 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

Just move the if statements in “app/design/frontend/default/[theme]/template/catalog/product/compare/sidebar.phtml, e.g.

<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design_blank
* @package Mage
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
?>
<?php if($this->helper('catalog/product_compare')->getItemCount()>0): ?>
<div class="block block-compare">
<div class="block-title">
<h2><?php echo $this->__('Compare Products - %d Items', $this->helper('catalog/product_compare')->getItemCount()) ?></h2>
</div>
<div class="block-content">
<?php if($this->helper('catalog/product_compare')->getItemCount()>0): ?>
<ol id="compare-items">
<?php foreach($this->helper('catalog/product_compare')->getItemCollection() as $_index=>$_item): ?>
<li>
<input type="hidden" class="compare-item-id" value="<?php echo $_item->getId() ?>” />
<a href="<?php echo $this->helper('catalog/product_compare')->getRemoveUrl($_item) ?>"><img src="<?php echo $this->getSkinUrl('images/list_remove_btn.gif') ?>” alt="<?php echo $this->__('Remove This Item') ?>” class="v-middle" onclick="return confirm(’<?php echo $this->__('Are you sure you would like to remove this item from the compare products?') ?>’);” /></a>
<a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList(’compare-items’)</script>
<div class="actions">
<a href="<?php echo $this->helper('catalog/product_compare')->getClearListUrl() ?>” onclick="return confirm(’<?php echo $this->__('Are you sure you would like to remove all item from compare products?') ?>’);"><?php echo $this->__('Clear All') ?></a>
<button class="button" onclick="popWin(’<?php echo $this->helper('catalog/product_compare')->getListUrl() ?>’,’compare’,’top:50,left:50,width=800,height=600,resizable=yes,scrollbars=yes’)"><span><?php echo $this->__('Compare Items') ?></span></button>
</div>
<?php else: ?>
<p><?php echo $this->__('You have no items to compare.') ?></p>
<?php endif; ?>
</div>
</div>
<?php endif; ?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
DnD Thomas
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2008-09-26
 

thank u so much for your quick answer !
Awesome !!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
my evil twin
Member
 
Total Posts:  34
Joined:  2007-08-31
Hamburg, Germany
 

thanks! useful for me, too grin

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top