Jump to content

How To Enable Pagination for Search Result


Stronach

Recommended Posts

Hello,

 

I'm having an issue enabling numbered pagination for search result, such as when searching for query without using Ajax, if I use /search/?q=example the pagination shows /search/2/, /search/3/ etc without specifying the actual query and when I use /search/example/ the pagination shows /search/example/2/ and so on and so forth but just shows a 404 error.

 

How would I fix this?

 

Thanks.

Link to comment
Share on other sites

  • 2 weeks later...

It can only be used without ajax for pages which have only videos list or albums list. In KVS default theme search page renders both videos and albums. It needs to be decomposited to render only one list at once, then pagination can be configured without ajax.

 

Here is an example. Currently search works via this URL:

http://domain.com/search/query/

 

So the pagination should be:

http://domain.com/search/query/2/

http://domain.com/search/query/3/

 

But since there are both videos and albums rendered, KVS will not know which list to paginate. Paginating both lists is not an option, since one of the lists will have less items than another and thus KVS will start showing 404 errors starting from some page number.

 

There can be 2 solutions for this problem in site design:

 

1) Render both videos and albums and instead of pagination control on the first page render "Show more" button, which will for videos go to videos search page #2 and for albums will go for albums path #2, e.g.:

http://domain.com/search/videos/query/2/

http://domain.com/search/albums/query/2/

 

These pages will render only videos or albums. This can be achieved within 1 page by template manipulations and using custom GET parameter to indicate search type. Then in template code check if this parameter == videos, then render only videos block with pagination, if this parameter == albums then render only albums block with pagination. If this parameter is not videos nor albums, then render both videos and albums blocks with "Show more" buttons instead of pagination.

 

2) Add search scope selector to search textbox so that user can initially select whether they want to search videos or albums. In this case javascript should be adjusted to change form URL to either

http://domain.com/search/videos/query/

or

http://domain.com/search/albums/query/

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...