Forums / Templates, Stylesheets, Page Layout / 3 items per page, except for some..

3 items per page, except for some..

Locked

Views: 1,202

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
5 Jun 2008, 8:39 PM
#1
mdewyer avatar

mdewyer

New Zenner

Join Date:
Jun 2008
Posts:
6
Plugin Contributions:
0

3 items per page, except for some..

Hey guys,

When displaying items in a category, I want to only show 3 items per page. That's no big deal, but, the client wants some pages to only show 2 item images, with one of the images taking up the space of 2 normal images. Ex:

Normal page:

|pic| |pic| |pic|

A few pages:

|pic| |---pic---|

So, some pages would have 3 images, and others have 2. I don't know what you'd even base it off of, but I wanted to know if it was do-able to begin with.

Thanks,

Matt

5 Jun 2008, 9:41 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: 3 items per page, except for some..

For starters, get the Column Layout Grid mod from Downloads. That will allow you to specify that the products appear side by side.

Then there is the issue of displaying the wide images, and only displaying two images per page when one is wide.
I don't have time to think about those tonight, but look at product_listing.php in the mod files and you may see a way to proceed. For the wide images, I would remove the percent width calculation and let the images control the space taken.

5 Jun 2008, 10:33 PM
#3
mdewyer avatar

mdewyer

New Zenner

Join Date:
Jun 2008
Posts:
6
Plugin Contributions:
0

Re: 3 items per page, except for some..

Yeah, it's not so much the issue of having an image take up the extra space, but rather of having the cart only pull 2 items from the database for a page, but only if one of the images is larger. Otherwise pull 3.

The database can't really determine that, and once you get past that initial pull from the database (if you'd do the logic in PHP), you'd loose using the database for the paging with it's LIMIT and OFFSET features. The database can't do the logic of "there's 30 items, and 3 per page, but on page 5, 7, and 8 there will only be 2 products since the images are wider, so that makes it 9 pages rather than 10".

Does that make sense? I just don't see how it is even possible, but maybe I'm missing something.

Thanks,

Matt

6 Jun 2008, 4:51 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: 3 items per page, except for some..

It may require another product field in the db for "width" or something like that. Once the db has the info, the php can be coded to account for all the ramifications of the wide images.

6 Jun 2008, 1:37 PM
#5
tdubpro avatar

tdubpro

New Zenner

Join Date:
Jun 2008
Posts:
1
Plugin Contributions:
0

Re: 3 items per page, except for some..

mdewyer:

The database can't do the logic of "there's 30 items, and 3 per page, but on page 5, 7, and 8 there will only be 2 products since the images are wider, so that makes it 9 pages rather than 10".

You're correct. Even if you were to add a field to the database to indicate that an image was bigger, it still doesn't solve the issue of determining the paging. The problem lies in the fact that a larger image would take the space of two products. So, if you pull three items and one has a larger image, it will be taking up a total of four widths, rather than three. And, if you'd hide one of the smaller images on that page (so you get to the needed three widths), then the database offset for the next page would be off, and the hidden product would not be displayed on the following page.

This is not an issue with ZenCart, but rather a limitation of what's possible with paging based off a database, like you explained. You can't, in a query, look at what you're about too pull and if one of the items has a larger image, only pull two, and still keep the paging intact, because the paging is going off of the fact that there are supposed to be three items per page, not three sometimes, and two other times. It throws the whole paging logic out of sync.

Sorry, but I think you're going to have to tell the client that it's not feasible.