ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

a solution to my question for using switch statement in reverse related entries

October 01, 2011 2:52am

Subscribe [2]
  • #1 / Oct 01, 2011 2:52am

    Brian_az

    36 posts

    This question may be related to a resolved thread.


    I found a solution to using a switch statement for rows on a related enrty. I can’t find the post I learned it from, but the code is below. They used php and set the template to parse php on the output in the admin.


    </p> <p>{reverse_related_entries orderby="date"}</p> <p>{if count =="1"}</p> <p><div align=“center”><br /> <table width=“920”><br /> {/if}<br /> <?php<br /> $columns = 4;<br /> $i= {count}-1;<br /> if($i % $columns == 0) {<br /> echo "<tr>\n"; //if there is no remainder, start new row<br /> }<br /> ?><br /> <td><br /> <a href="http://{channel_field}" target="blank" rel="noopener">_{channel_field}</a></p> <p><span class="smalltext">{title}</span><br /> Creation date: {channel_field}</p> <p>{channel_field2}<br /> </td><br /> <?php<br /> if(($i % $columns) == ($columns - 1) || ($i + 1) == {total_results}) {<br /> //if there is a remainder of 1 or no results left, end the row<br /> echo "</tr>\n";<br /> }<br /> ?><br /> {if count == total_results}<br /> </table><br /> {/if}</p> <p>{/reverse_related_entries}</p> <p>

    Works great for me, I can now do

    img1 img2 img3  

    Thanks!!

  • #2 / Oct 01, 2011 8:42am

    Sue Crocker

    26054 posts

    Thanks for posting your solution… If anything else comes up, please do let us know in a new thread..

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases