1

I'm using the HTML List format for my View, which has three fields (nid and title, both excluded and Custom Text).

The content of Custom Text is as follows:

<li class="inspiration portfolio" data-content="#colio_c[nid]">
<a class="button colio-link" href="#">View Project</a>
<h4><a class="colio-link" href="#">[title]</a></h4>
<p>Lorem Ipsum</p>
</li>

I've noticed that using the <li> item in my Custom Text field will result in an empty <li> item wrapping my content. As such, the output I get from this is as follows:

<div class="view-content">
<div class="item-list portfolio"> 
<ul class="list">          
<li class="">  
<li class="inspiration portfolio" data-content="#colio_c7">
<a class="button colio-link" href="#">View Project</a>
<h4><a class="colio-link" href="#">Item 1</a></h4>
<p>Lorem Ipsum</p>
</li></li>
<li class="">  
<li class="inspiration portfolio" data-content="#colio_c8">
<a class="button colio-link" href="#">View Project</a>
<h4><a class="colio-link" href="#">Item 2</a></h4>
<p>Lorem Ipsum</p>
</li></li>
</ul>
</div>
</div>

My question to you is: How do I remove those empty <li class=""> tags?

I tried to set wrapping element to none but to no avail. I've also attempted to do it with an unformatted list and create everything in custom text but then I'd have a <ul> for each row and I do not have access to data-content="#colio_c[nid] that way.

An export of my view is available at http://ideone.com/KyNGO4

0

It sounds like you want to override the row style output so that it doesn't output the wrapping li tag. There are other posts on here asking about that process. To get started though, in views, expand the Advanced section and click "Theme" - a window will then pop up showing you information on the template files for your theme.

  • Ok, looking in to the theme section, this is what I did: – user27448 Mar 23 '14 at 14:07
  • For Row Style Output, I created a new template file that removed <?php print $field->wrapper_prefix; ?> and <?php print $field->wrapper_suffix; ?>. This got rid of the extra <li> tags, but now I still needed an <ul> wrap. Going into Style Output, I made a new template file with: <ul class="portfolio"> <?php foreach ($rows as $id => $row): ?> <?php print $row; ?> </div> <?php endforeach; ?> </ul> This gave me the desired result. You reckon this is the best way to go? – user27448 Mar 23 '14 at 14:14
  • It's up to you which way you go. Having template files is certainly more flexible for developers, but less flexible to control things in the views interface. To reduce the number of template files to maintain, you could alternatively ensure the view format is set to "HTML list", and then in the view style options set the "List class" to "portfolio". – alexkb Mar 24 '14 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.