Skip to main content
Participant
April 28, 2008
Question

Spry:if

  • April 28, 2008
  • 1 reply
  • 321 views
In Dreamweaver I have a spry table that displays products. I would like to filter the table on the type of product. I have found some code and tried to ammend that. This uses the Spry:if statement, However no rows are being displayed. The test below is meant to check if the first character is b o or c.
Basically I cannot find a good explanation of spry:if, Spry:when, Spry:test, spry:choose to resolve this.

Any suggestions please.

<div spry:region="dsProductTypes" spry:if="{ds_RowCount} != 0" >
<table>
<tr>
<th spry:sort="SubType">SubType</th>
</tr>
<tr spry:repeat="dsProductTypes" spry:test="'{Type}'.match(/^[boc]/i);" spry:choose="" spry:odd="OddRow" spry:even="EvenRow" spry:hover="" spry:select="">
<td>{SubType}</td>
</tr>
</table>
</div>

This topic has been closed for replies.

1 reply

Participant
July 17, 2008
This may not help you a lot but here is how I handled alternate row coloring:

In my CSS file I defined the coloring
tr.normal { background-color:#14285F; }
tr.alternate { background-color: #293F78; }

In my web page, I did this:
<?php
$trclass = ($row_count % 2) ? "normal" : "alternate";
?>
...a bunch of other code and HTML lines...
<tr valign="top" class="<?php echo $trclass; ?>">

As for the "spry:if" business, I just used it a minute ago in another page.

What my code is doing is displaying a gallery of my web work. One of my data fields, "{siteURL}", can contain either a comment (my comments are bracketed with the '[' and ']' characters) or an actual URL.

If the "{siteURL}" field contains a comment, I merely display the comment.

If the "{siteURL}" field contains a URL then I display the URL as a clickable link to the actual web page. I did this because it would make no sense to be able to click on a 'comment' and therefore pull up an Error 404 page!!!

To test my code, I used a "spry:if" statement and it worked fine - no problems.
For the real life situation, I actually needed an 'if...else' construct so I had to swap my "spry:if" statement for a "spry:choose" statement (there is no such thing as a "spry:else" statement).

Perhaps you can look at my code and figure out from it, what you might need to do with your code - honest, "spry:if" DOES work!:

<div style="display:inline; font-size:10px; color:#555555" spry:detailregion="dsGalleries">
<div style="display:inline;" spry:choose="spry:choose">
<div style="display:inline;" spry:when="'{siteURL}'.search(/\[/) != -1;">{siteURL}</div>
<div style="display:inline;" spry:default="spry:default"><a href='{siteURL}' target='_blank'>{siteURL}</a></div>
</div>
<br /><br />
</div>

I hope all this might lead you in the right direction... good luck!