OK. I have a simple {switch} to add alternating classes on table rows. Classic example.
My problem is that before the < tr > loop I have inserted a check to see if the entry being returned from the db is the actual entry that the viewer is viewing. That is I’m returning a list of news items, and I want to exclude ‘article x’ if ‘article x’ is what’s currently being viewed.
My code is as follows:
{if segment_3 != url_title}
<tr class="{switch='odd|even'}{if sticky=="y"} sticky{/if}">
<td>
some stuff here
</td>
</tr>
{/if}(Full code at the bottom of the post, in case it matters)
The problem is that the entry which is skipped (that’s all working properly) is somehow still being allotted a class, which means that the two table rows adjacent to the “missing” article get the same class (classes are ‘even/odd’ in this case), which means that they each get ‘even,’ they get the same class, hence the same coloring.
Seems to me that the {if} should remove the returned entry from the count, no? Unless I fix it somehow, an example is viewable at http://queensvw.com/indexx.php/news/detail/cctv
Look at the “Latest News” block on the middle right to see two entry summaries with gray backgrounds. They’re supposed to be alternating. Now, if you click on any other of the links in that “Latest News” section, you will see the alternating backgrounds. Seems like (for now, since I only have these few sample stories) that the CCTV article is the one “between” the two “even” rows.
I’m still thinking that switch should only be acting on *returned* results, not total possible results before filtering. Am I missing something?
Full Template Code for “Latest News” Section
<div id="latest" class="grid_{embed:grid_size}">
{exp:channel:entries channel="news" disable="pagination| member_data| custom_fields| categories" limit="8" orderby="date" sort="desc" dynamic="off"}
{if count == "1"}
<h2>Latest News</h2>
<p> <table class="latest_item" summary="Latest news and website postings from Queensview, Inc."><br />
<tr><br />
<th>Date</th><br />
<th>Description</th><br />
</tr><br />
{/if}</p>
<p> {if segment_3 != url_title}<br />
<tr class="{switch='odd|even'}{if sticky=="y"} sticky{/if}"><br />
<td class="latest_date"><br />
<span class="latest_date_wrap"><br />
{if sticky=='y'}<br />
/assets/site/site_images/info_48.png<br />
{if:else}<br />
<span class="month">{entry_date format="%M"}</span> <br />
<span class="day">{entry_date format="%d"}</span><br />
{/if}<br />
</span><br />
</td><br />
<td class="latest_text"><br />
<a href="http://{comment_auto_path}{url_title}">{exp:low_widont}{title}{/exp:low_widont}</a><br />
{if summary} <br />
{exp:tagstripper:stripAllTags}{exp:low_widont}<br />
{summary}<br />
{/exp:low_widont}{exp:tagstripper}<br />
{/if}<br />
</td><br />
</tr> <br />
{/if}</p>
<p> {if count == total_results}</table>{/if}</p>
<p> {/exp:channel:entries}<br />
<a href="http://{path=news}id=all_news_link"><span>See All News…</span></a><br />
</div>