Skip to main content
added 187 characters in body
Source Link
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', with the 'parent-items' part being the name of my view (in my case, a 'Content Pane'. You'll see already customised file names for use with Panels)your particular view under 'Theme: Information'.

In this file (placed in the root of your theme directory) 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, which can be found under the replacement patterns section for each field.

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 suggested workaround.

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.

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', with the 'parent-items' part being the name of my view. You'll see already customised file names for your particular view under 'Theme: Information'.

In this file (placed in the root of your theme directory) 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, which can be found under the replacement patterns section for each field.

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 suggested workaround.

Source Link
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.