Issue
Most Fences templates render out field items with a foreach loop and call render()
over each item. The render call is wrapped in some HTML for the respective element, For example, field--fences-strong.tpl.php.
The issue arises when the item may not be visible in its current scope, I.E. $item['#access'] = FALSE;. The render function obeys this and does not render the item, however fences still wraps the item which leads to dirty markup.
Proposed Solution
When fences will contribute a template suggestion to a rendering field (in hook_preprocess_field), it should also sanitize the items variable to ensure only visible items are passed to the template.
See patch attached.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2064675-fences-field-visibility-fix.patch | 742 bytes | Josh Waihi |
#1 | 2064675-fences-field-visibility-fix.patch | 1.36 KB | Josh Waihi |
fences-render-visible.patch | 612 bytes | Josh Waihi |
Comments
Comment #1
Josh Waihi CreditAttribution: Josh Waihi commentedI found the previous patch mismatched existing elements and still broke fences integration. This patch now address and fixes the issue correctly.
Comment #2
Josh Waihi CreditAttribution: Josh Waihi commentedWrong format. Here is the patch with the correct formatting.
Comment #3
JohnAlbinHmmm…
This is a core bug, no? Core's default theme_field() has the same behavior. https://api.drupal.org/api/drupal/modules%21field%21field.module/functio...
I'm hesitant to work-around this in Fences without a corresponding issue in core.
Comment #4
Anybody