Use Lists for Entries and Comments
Posted: 27 November 2008 11:53 AM   [ Ignore ]  
Grad Student
Rank
Total Posts:  31
Joined  03-16-2008

I like my blog entries and comments to display as list items so they can be easily styled.

However,

in the following situation:

<ul id="comments_list">
    
{exp:comment:entries sort="asc" limit="20"}
        
<li>
            
{comment}
            
<p class="author">By {name} on {comment_date format="%Y %m %d"}</p>
        </
li>
        
{/exp:comment:entries}
</ul>

everything works fine if there are comments.  However, when there are no comments it results in a set of ul tags with no contents which is an XHTML invalidation.

Obviously there is a if-exists condition but this only evaluates when inside exp:comment:entries.

How can this be tested outside the UL tag in an elegant way?

Profile
 
 
Posted: 27 November 2008 12:00 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  31
Joined  03-16-2008

Fixed with…

{if comment_total != 0}
<ul id="comments_list">
    
{exp:comment:entries sort="asc" limit="20"}
        
<li>
            
{comment}
            
<p class="author">By {name} on {comment_date format="%Y %m %d"}</p>
        </
li>
    
{/exp:comment:entries}
</ul>
{/if}

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66389 Total Logged-in Users: 45
Total Topics: 84714 Total Anonymous Users: 18
Total Replies: 454687 Total Guests: 190
Total Posts: 539401    
Members ( View Memberlist )