Skip to main content
1 of 2
PUncle
  • 171
  • 2
  • 13

The credit really goes to Alex Gill above for suggesting this, but as he didn't leave it as an answer (or give any details ;), I figured that I should.

In Views 3, the last option under 'Advanced' (the third column) is 'Theme: Information' - clicking this get you a whole bunch of override suggestions. In my case I created a new template file called 'views-view-fields--parent-items.tpl.php' 'parent-items' part being the name of my view (in my case, a 'Content Pane' for use with Panels).

In this I used conditionals to check if each field existed, before printing it out with the li tags inside those conditionals. See below:

<ul id="parent-items">
    <?php if (!empty($fields['name_5']->content)): ?>
        <li><?php print $fields['name_5']->content; ?></li>
    <?php endif; ?>
    <?php if (!empty($fields['name_4']->content)): ?>
        <li><?php print $fields['name_4']->content; ?></li>
    <?php endif; ?>
    <?php if (!empty($fields['name_3']->content)): ?>
        <li><?php print $fields['name_3']->content; ?></li>
    <?php endif; ?>
    <?php if (!empty($fields['name_2']->content)): ?>
        <li><?php print $fields['name_2']->content; ?></li>
    <?php endif; ?>
    <?php if (!empty($fields['name_1']->content)): ?>
        <li><?php print $fields['name_1']->content; ?></li>
    <?php endif; ?>
</ul>

[name_1] to [name_5] are my field names.

In order to have this work well I also disabled all markup generated by views.

Thanks Alex for the idea, and Елин Й. for a pretty clever workaround.

PUncle
  • 171
  • 2
  • 13