Loading...
 
Skip to main content

Development


Listing Template Optimization

A little suggestion on how to avoi code duplication for odd/even rows in templates for table listings.

instead of duplicating the row's template code, just set a local variable with the interested css class:

{if $smarty.section.user.index % 2}
{assign var="rowclass" value="odd"}
{else}
{assign var="rowclass" value="even"}
{/if}

then use the variable to set the class in the cells:

<td class="{$rowclass}">cell code here</td>

Of course this is valid only if odd and even rows have same contents and differ only for style settings.