[themes] how to exclude a View-field when not present?

Nat Meysenburg nat at openflows.com
Thu Dec 3 05:50:43 UTC 2009


sebastian wrote:
> I have a view, and I am using the check box on the image_field:
> 
> [x] Rewrite the output of this field
> 
> And below it, I have wraped my output in some DIV tags that add drop 
> shadows.
> 
> Only, not all my Node's have an image, which is the way it should be 
> [flexible]; only Drupal still renders the wrapping DIVs instead of 
> seeing that there is no content, and not theming the field... 
> consequently, I get drop shadows when it makes no sense.
> 
> Does anyone know how to resolve this and stop Views from rendering 
> supporting tags when using "rewrite output"?

I'm a little late on this thread, and maybe I'm overlooking something
but is there a reason you can't add the CSS drop shadows to the img
element itself?

What I mean is that your default field output should provide a div
identifier for the field, or failing that, one for the view. Within that
cascade of unique and generic named elements you should be able to find
the right selector to do something like ".view-field-image img" in your
CSS, and have it only affect the images in the context of your view.
Furthermore, since the CSS value is attached to the image tag itself,
the lack of an image will mean that the rule will simply not be called -
unlike your case of empty custom divs.

~~nat


More information about the themes mailing list