On April 27, 2024, our Sign-in and Create Account options will be unavailable from 9am-12pm ET. During this maintenance window, developer account access and free trial registration will be unavailable.

Alternating rows

I am rusty with template\ing so bear with me. Took the classes 3 months ago and just now using the knowledge.

I have a page that will contain a list of events. Each event will be in it's own row in a table. The rows alternate in colors ie. gray, white, gray, white etc. There is a need for an unlimited number of events and rows.

I am needing to template this page with replicants. I can template it is using replicants with each inserted into an already created table with an x number of rows with each already colored.

How can I create a replicant that contains a white row with a text field and a gray row with a text field. These replicants will be placed inside the <table> tag within the tpl. This would create the table I am looking for.

Please help.

Thank you.

Comments

  • Chris_24,

    Try this. I don't actually use this, I just modified a piece of code we use that's close.
    There may be an issue with typecasting of variables, I'm no where near an expert in this.

    I would be interested to know if it works.

    Dan Bowker

    <iw_iterate var="whatever" list="dcr.Field name" iteration="counter">
    <iw_if expr="({iw_value name='$counter'/} % 2) eq '0'">
    <iw_then>
    <![CDATA[
    <td bgcolor="#cccccc">what ever you want on a gray background</td>
    ]]>
    </iw_then>
    <iw_else>
    <![CDATA[
    <td bgcolor="#ffffff">what ever you want on a white background</td>
    ]]>
    </iw_else>
    </iw_if>
    </iterate>
  • You are my hero...

    With just a couple minor tweaks, it worked wonderfully. Here is the exact code I ended up with:

    <table width="100%" border="0" cellspacing="0" cellpadding="8">
    ]]>
    <iw_iterate var="classifieds" list="dcr.Classifieds" iteration="counter">
    <iw_if expr="({iw_value name='$counter'/} % 2) eq '0'">
    <iw_then>
    <![CDATA[
    <tr bgcolor="#dcdcdc">
    <td class="prodguide">
    ]]>
    <iw_value name="classifieds.Ad" />
    <![CDATA[
    </td>
    </tr>
    ]]>
    </iw_then>
    <iw_else>
    <![CDATA[
    <tr bgcolor="white">
    <td class="prodguide">
    ]]>
    <iw_value name="classifieds.Ad" />
    <![CDATA[
    </td>
    </tr>
    ]]>
    </iw_else>
    </iw_if>
    </iw_iterate>
    <![CDATA[
    </table>


    Thank you very much...

    Chris Simpson ~ csimpson@gfs.com
    Web/Multimedia Developer
    Gordon Food Service ~ www.gfs.com