Topic: Understanding ROWCNT
I feel under qualified to talk about this subject, but it is a discussion/tutor that many may or may not need. My logic may not be spot on, but it works.
SCENARIO
To illustrate this problem lets look at the call I have for my videos on my site.
{videos:limit=12,cache_time=0,cache_name="yout"}
Note in the call that I am displaying 12 videos in the call.
Now lets look at the image for the above call

If you are like me, you look at the above image and wonder what happen. I'm calling 12 images. There are 4 images in the first two rows. Why did it not display three rows of 4 images? 12 divided by 3 = 4 so why is the math off? As you can see in the third row there is only 3 images and the 4th image goes to the next line. It has to do with ROWCNT.
THE EXT
Lets look at the ROWCNT used in my extension for the above call. In this case the extension is ext.videos (note, you may or may not be using this ext. It does not matter for this tutor. It could be the member extension that displays new members. The point of this tutor is to understand ROWCNT).
My video ext has a ROWCNT that looks like this:
<!-- IF rowlast OR rowcnt mod "11" == "10" -->
In this ROWCNT the numbers 11 == 10 is the key to how your images will display on your site.
ANALYZING VLAD'S COMMENTS
I asked vlad once about ROWCNT and this was his reply:
1. rowcnt is pulled from a "for loop". When something is stored in array (for example search results), you check which row you're on by using that variable.
2. To insert some code after every 4 items, use this code <!-- IF rowcnt mod "4" == "3" --></tr><tr><!-- ENDIF -->
3. It inserts tr/td after specific number of items is reached. For example above code will insert new line after every 4 items
<table>
<tr>
<!-- BEGIN variable -->
<td>member picture</td>
<!-- IF rowcnt mod "4" == "3" --></tr><tr><!-- ENDIF -->
<!-- END variable -->
</tr>
</table>Well word by word explanation of the above is: if remainder of "rowcnt" value divided by 4 equals to 3, then we insert a new row. "rowcnt" starts with 0 and increases by 1 with each new iteration. You can try this using your windows calculator:
0 mod 4
1 mod 4
2 mod 4
3 mod 4
4 mod 4
5 mod 4
etc You'll see that every 4 times there will be a remainder of 3.
I really appreciated vlad taking the time to provide such thorough feedback. Now I just needed to try to figure it out. I knew I would need pencil and paper along with my trusty calculator to do so.
First off, if you are like me, you could easily guess what to change your ROWCNT numbers to that may fix the problem. I do that a lot. I use trial and error until I get it right even if I don't understand why it works.
What would you change the 11 == 10 in my extension to get even rows of 4? Would you use 12 == 10 or 11 == 12? If you guessed 11 == 12 you were right, but do you know why?
PENCIL AND PAPER
The key in vlad's comment was this: "if remainder of "rowcnt" value divided by 4 equals to 3, then we insert a new row." In my extension I'm dealing with 11 == 10. So I would say: if the remainder of rowcnt value divided by 11 equals 10, then we insert a new row.
Now the boring part. Lets get our calculator out and do the math.
0 / 11 = 0 (no new row)
1 / 11 = .090 (no new row)
2 / 11 = .18 (no new row)
3 / 11 = .27 (no new row)
4 / 11 = .36 (no new row)
5 / 11 = .45 (no new row)
6 / 11 = .54 (now new row)
7 / 11 = .63 (no new row)
8 / 11 = .72 (no new row)
9 / 11 = .81 (no new row)
10/11 = .90 (no new row)
11/11 = 1 In my above image, this is where the spit happen in the 3rd row. Once it reached 11 images, the next image went to the next row. Do you see why?
Look at this explanation again:
"if the remainder of rowcnt value divided by 11 equals 10, then we insert a new row" What is the remainder of 11/11=1? Do the math. subtract 1 from 11, what do you get - 10. And what does 10 equal in the formula - a new row.
Ok, for what it is worth, that is my logic for understanding ROWCNT. I probably made it too complicated so if anyone has an easier or simpler explanation, I'm all ears. But if you do not want to do the math, you can always do what I do, guess ![]()