First off, thanks in advance, you guys all rock.
Here’s my issue.. I’m trying to do something seemingly simple.. write a template that will display the contents of a weblog (an artists “works”), in a grid, but ONLY works that fulfill a condition (are “Available”). I’ve tried this a number of different ways, but seem to keep running into an issue around php / template processing order. The results are simply not consistent.
Here’s my code:
<h3>AVAILABLE WORKS</h3>
<p><?php <br />
$counter = 0;<br />
?><br />
<table border="0" cellpadding="6" align="center"><tr><br />
{exp:weblog:entries weblog="titus_works" sort="asc"}</p>
<p> {if work_status == "Available"}<br />
<td valign="top"><a href="http://{url_title_path=" target="_self" rel="noopener">{work_thumbnail}</a></td><br />
<?php<br />
echo $counter;<br />
if (($counter % 5) == 0) {<br />
echo '</tr></table><table cellpadding="6" align="center"><tr>';<br />
}<br />
$counter++;<br />
?><br />
{/if}<br />
{/exp:weblog:entries}<br />
</tr></table>Trouble seems to be centering around the “if work_status” line..it it incrementing “counter” on every loop, NOT just on the loops where the work is “Available”.
Is there something dumb i’m missing here, or a different way to accomplish the same? I was getting strange results when i did it the “easy” way too, with
{if count == 5 || count == 10 ..etc }I could probably get that way to work, but the “%” php method is so much more elegant.
Thoughts?