Forums / Setup & design / classification for <tr>

classification for <tr>

Author Message

Antoine W.

Friday 01 July 2005 6:00:37 am

Is it possible to use classification for <tr> ?
In example :

<table>
<tr class='normal'><td>blah</td></tr>
<tr class='alternate'><td>blah</td></tr>
</table>

Thanks

Antoine W.

Tuesday 05 July 2005 2:30:24 am

Sorry to insist, but I really need to know if classification for table rows is allowed or not.
When I try to set a "class" attribute for <tr>, it's not accepted.

So how should I proceed to build a beautiful table with an alternate background color for rows ? Should I set classification for each cell of the row ?

Thanks !

Peter Putzer

Tuesday 05 July 2005 3:40:54 am

Strangely enough, <tr> doesn't support a classification in eZ publish XML.

I've got no idea why and at first I tried to hack the kernel to get those alternative row colors. But this proved to be more difficult than expected and there was a much easier way:

{let classification=""}
{section show=$row_count|ne(0)}
	{section show=$row_count|mod(2)|eq(1)}
		{set classification="bgdark"}
	{section-else}
		{set classification="bglight"}
	{/section}
{/section}
<tr {section show=ne($classification,'')} class="{$classification}"{/section}>
{$content}
</tr>
{/let}

On the negative side, you don't have control over the shading. On the plus side, it happens all automatically and the XML code is much shorter (which is a gain especially for long tables).

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

Antoine W.

Wednesday 06 July 2005 5:35:15 am

Thanks for your solution, Peter !