Jump to content

Pagination /w dynamic limit or start/end


Sebastian
 Share

Recommended Posts

I'm trying to wrap my head around the following concept, code-wise:

I do have a list of companies (let's say 100+) und would like to display them on an page, with pagination.
So far so good, no issue there - works perfectly fine.

Also I've grouped the company list output by the first character of the company name, so i.e. in the [A] section there's amazon, apple etc.
This is done on the frontend only, I still get the company list by

$pages->find("template=location,limit=$limit,sort=title")

I've created a subnav on top of the page which lists all the character sections that have companies in them (for example there's no company beginning with 'z', so that char isn't listed in the nav).
If I click on one of these characters in the subnav, I jump to the section using a link like this: domain.com/company/page3#char-M.
This also works fine. Broadly speaking I'm doing something like

$page_num = intval(ceil($companies/$limit));

to get the correct page number and add the jump link at the end.

The issue is though that by using a hard limit on the pagination, I basically split the pages while the listing of the character section isn't complete.
So domain.com/company/page3#char-M does indeed get me to the start of the "M" section, but on /page4 "M" continues since there are more companies, which is unfortunate for a number of reasons.

I'd like to list the companies in that section completely, then start the next character section *on the following page*.

Has anyone done this using the built in pagination (or in another way) and could point me to how this can be achieved? There's a lot of moving parts involved and I'm not sure how to tackle this, any pointers would be much appreciated!

 

Link to comment
Share on other sites

Have you thought of doing it with url segments?

/companies --> list all companies, maybe with pagination
/companies/page1
/companies/page2

/companies/a --> list all companies starting with "A"...
/companies/a/page1
/companies/a/page2

/companies/b --> "B"...
and so on

Not sure if the overall listing would then be necessary at all. Also I'm not sure what that would mean in terms of duplicate content - maybe we have SEO experts here that can tell us something about that?

But I think from a logical point of view it's not possible (or not wise) to try to show companies with a special letter in the non-letterised company-listing (like /companies/page6#m) as that could also mean that you have 99 entries of companies with N and only one entry with M. You wouldn't have this problem when using url segments like /companies/m

  • Like 1
Link to comment
Share on other sites

Thank you Bernhard, good thinking/ideas there!

I did indeed not think of url segments so far, I'll give it a try. With some js sprinkled on top this looks like a nice filter-y solution!
Wrt to SEO I'll talk to my people but even if it's problematic that should be easy to fix. Thanks again!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...