Hide Attribute if Attribute Value is Empty Space in Magento

attributesproduct-attributeproducts-view

app/design/frontend/default/theme/template/catalog/product/view/attributes.phtml

http://pastebin.com/6uzYgauE

this is the attributes.phtml file we are using to display the attibutes in frontend.

suppose if attribute value is empty , than thiose attributes will not display in frontend for the

particular product.

but if we give some empty space in the attribute text field, than those attributes are displaying in the frontend.

if we gave empty space as attribute values , than we want to hide those attributes for the particular product.

ex: if attribute color = "" than color will not display in frontend

if attribute color = " " than color will display in frontend. we want to hide color here….

please help me to find solution.

Best Answer

to hide empty spaces in the attribute values, you can use the below code in the attributes.phtml file.

$attribute_value = 'xyz';
if (strlen($attribute_value) > 0)
{
   // code to display the value
}
Related Topic