我有一些代码可以创建一个表,该表根据条目的行值交替行颜色。
<table class="authorList" cellspacing="0">
{exp:channel:entries channel="team" disable="categories|member_data|pagination" orderby="team-last-name" sort="asc"}
{if team-not-with-us != 'y'}
<tr class="{switch="odd|even"} authorInfo">
<th class="authorName">
{if team-bio != ''}<a href="{site_url}about/the-team/{url_title}">{/if}
{title}
{if team-bio != ''}</a>{/if}
</th>
<td class="position">{team-position}</td>
</tr>
{/if}
{/exp:channel:entries}
</table>
问题是当我删除一个条目时,我最终会连续有两个奇数或两个偶数,留下两个并排的颜色相同的行。
虽然 switch 函数很方便,但它引用了数据库中的行数。我不相信我可以应用它来引用 if 语句中的实际行数,这可以解决我的问题。(如我错了请纠正我。)
我知道如何使用 php 进行此更改:
<?php $oddevenrow = 0; ?>
{if team-not-with-us != 'y'}
<?php $oddevenrow++; ?>
<?php ($oddeven = ($oddevenrow % 2 ? 'odd' : 'even')); ?>
<tr class="<?php echo $oddeven; ?> authorInfo">
但是我不允许在 EE 安装中打开 PHP。
我可以在 EE 中做类似的事情吗?
谢谢!