views:

139

answers:

2

The project is developed using CakePHP.

The page is of a news feed article.

Pagination is simple when you want to return (x) number of records per page, or (x) number of images per page, or even limit the number of words/paragraphs/characters but what if you want to paginate by the visual length of the page?

The issue came up because some articles contain a large amount of text and a large amount of images. I would like to know how you would go about developing pagination when the content is completely dynamic. By this I mean, it could be 100% text, text and 3 pictures, 10 pictures, etc.

Code is appreciated but even a concept would be beneficial, thanks!

A: 

I don't know cakephp, but, how about counting the number of characters?

Let's say you have 10.000 characters in the article and you decide that each page should have not much more than 500 words. Given an average word lenght of 5 characters, you go to the character 500*5=2500, look for the next closing paragraph, and take this point as next-page mark. You could use the same concept with images but considering the height of the images...

Sounds good?

The Disintegrator
You could also consider the average area that a character uses, since you can find out the exact area your images use and know the amount of "area" each page should use. If you subtract the image area from your desired area, then divide by character area, you will know (roughly) how many characters you want.
deizel
A: 

Because we know the width of the page and the height of the image and we were able to approximate the pixel height of the text.

We then took the height of the images, spaces, and text, and subtracted that from the total allowable height within a certain percentage of error, this is so that it doesn't push an image onto the wrong page just because the last 10px go over the limit.

We also have a way to force items onto the previous page in the event that an image, or sentence gets pushed to the next page which does not give the proper look.