Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Product rows


Go to End


1143 Views

Avatar
aarono

Community Member, 34 Posts

8 October 2009 at 2:06pm

Edited: 08/10/2009 2:26pm

Hi there

This is my first time using the forum so please bear with me

Im trying to get all the products to appear in a rows of 4. So every set of 4 product items would be containted in a <div class="product_row">. I figured it would need to use modulus for this so i made a function:

function startRow() {
	if(($this->Pos() % 4)==1) {
		return true;
	} 
}

that works fine to start the row. however if i use the same idea to end it

function endRow() {
	if(($this->Pos() % 4)==0) {
		return true;
	} 
}

and i dont have an amount of products that is a multiple of 4 (4, 8, 12, 16 etc), it wont close the div.

Can anyone help?

Cheers,
Aaron

EDIT - SOLVED. the answer was right infront of me. if(($this->Pos() % 4)==0 || $this->Last())