In my layered navigation I want to be able to theme the content for each attribute differently. I have done this by creating my own version of app\design\frontend\base\default\template\catalog\layer\view.phtml and adding a class with the attribute name (which I can then target with css) by modifying this line from
<dd><?php echo $_filter->getHtml() ?></dd>
to
<dd class="<?php echo $this->__($_filter->attribute_model->attribute_code) ?>"><?php echo $_filter->getHtml() ?></dd>
This works fine but I noticed I was getting the following error in my log at this line:
ERR (3): Notice: Trying to get property of non-object in app/design/frontend/mytheme/default/template/catalog/layer/view.phtml on line 53
Fortunately, it's invisible on the front end and I'd like to eliminate it.
It dawned on me that this happens when the layered navigation is in a category tree and so there are no active attributes. I have tried to test if an attribute exists using the likes of is_object but nothing's worked and it's exhausted my admittedly limited PHP skills.
Can anyone suggest a way that works?