Magento Forum

   
showing a link if an attribute is set to “yes”
 
dolcezza
Jr. Member
 
Total Posts:  13
Joined:  2008-11-08
 

I am trying to show some thext and a link in the product page only if attribute is set to yes, but I cannot get it working.
I made an attribute called custom_art in the admin.

I edited catalog.xml:

<reference name="product_list">
<
action method="addAttribute"><attribute>custom_art</attribute></action>
</
reference>

I added things from different threads in here.

If I put this in my view.phtml, it appears on the front end as /yes. so it is finding the attribute:
<?php $_product->load($_product->getId()); ?>\
<?php echo $_product->getResource()->getAttribute('custom_art')->getFrontend()->getValue($_product); ?>

But this doesn’t work
Here is my view.html:

<?php // custom_art ?>
        
<?php if ($_product->getData('custom_art')): ?>
            <?php $_custom_art
$_product->getResource()->getAttribute('custom_art')->getFrontend()->getValue($_product); ?>
                <?php 
if ($_custom_art=="1"){ ?>
                        
<img src="<?php echo $this->getSkinUrl('images/btn_mini_search.gif') ?>" alt="More info"/>
                
<?php } else { ?>
                        
<img src="<?php echo $this->getSkinUrl('images/media/color-ivory.gif'); ?>"/>
              
<?php } ?>
        <?php 
endif; ?>

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