I’m using the following section of code to display some icons on our Magento store with the idea being if there is nothing added in the icons section it shouldn’t display, for some reason this isn’t working…it is displaying a division as if something is there but there is actually nothing.
<?php
if($_helper->productAttribute($_product,($_product->geticons()), 'icons') !== null):
?>
<div class="product-icons">
<?php echo $_helper->productAttribute($_product,($_product->geticons()), 'icons') ?>
</div>
<?php endif; ?>
It needs to show Icons if they are coded in the attribute field and then hide the division if there is nothing added.
I’ve worked out that the code is returning a value of string(0) what do I need to change in my coding to get the desired effect?
Here’s the thing you need, and you don’t need call the same functionality twice to get the empty result. Define your variable and check if it is empty (null, undefined or false) or not
this could be even better solution as it wont call the helper unless there are icons defined but you first have to try it out on your codebase.
and please check if it isn’t a typo and it really is:
or should it be