Member
Member
Michel   07-07-2013, 12:08
#1

Hi all,

I changed the sort order on the searchpage by doing this:

``

This works...latest pictures on first page, first pictures on last page.

On the first page with the latest pictures the printPageListWithNav shows the previous link instead of the next link.

printPageListWithNav( gettext('« Prev'),gettext('Next »'),false,'true','pagelist','',false,'7' );

Is there a way to change this?

TIA

Member
Member
sbillard   07-07-2013, 17:02
#2

Right off hand I do not see a way. What is needed is to set the search sort type/direction at the beginning of the script so that it is used by anyone fetching the images (e.g. next/prev).

This would be a reasonable new feature. Maybe create an issue requesting it.

Member
Member
sbillard   07-07-2013, 17:30
#3

I did think of a way to do this with the current software. A bit obscure, but I believe it will work.

You will need to create your own search object that extends searchEngine. Your object constructor should set the internal image and album sort variables to the values you want. Then your script would need to instantiate your object and store that into the $_zp_current_search variable.

Thought of a second thing to try. Searches are cached, so what you need to do is call a dummy next_image before anything else to get the list in the correct order. All else (presuming they do not pass sort parameters) will just use that cached list.

Member
Member
Michel   28-09-2013, 21:53
#4

Hi sbillard,

I saw on github that you worked out this feature. Today I checked my website with `` again and it works....but not 100%.

With the code I get the latest pictures on the first page and the first pictures on the last page. The code with the printPageListWithNav in my first post also worked.

After a search input I get the search output, say 16 thumbnails on 1 page. When I select 1 thumbnail (this goes to a 600x400px image) and press next for the next 600x400px image the order is not as in the thumbnail search output.

Am I missing something here in the code....

Extra links:

https://github.com/zenphoto/zenphoto/issues/458
https://github.com/zenphoto/zenphoto/issues/459

I really appreciate all your work on zenphoto.org.

TIA

Michel

Member
Member
sbillard   29-09-2013, 00:49
#5

Probably you are missing something. If all you have is the next_image loop it does not globally set the order (as mentioned in issue #459.)

You need to set the direction globally with the search engine method setSortType($type,$what). Ideally this should be done as one of the first things in your script to insure that no code has fetched search results before you have set the direction.

Member
Member
Michel   29-09-2013, 14:34
#6

Hi sbillard,

I read the github issue#459, but I don't get it.

Can you give me a example how to implant this into a search.php?

TIA

Administrator
Administrator
acrylian   29-09-2013, 15:56
#7

Place the function sbillard referred to at the beginning of your theme's search.php file and set its parameters as wished.

Member
Member
Michel   29-09-2013, 16:45
#8

Hi

The function does not work like this:
``

I'm confused right now :-)

TIA

Administrator
Administrator
acrylian   29-09-2013, 17:04
#9

No, of course not since the function is a search method as mentioned above. You need to use it with the current search object $_zp_current_search->setSortType().

Member
Member
Michel   29-09-2013, 18:42
#10

Hi,

Thnx for your explanation, at the beginning of my search.php i have this now:

`

`
Still a no-go.

TIA

Administrator
Administrator
acrylian   29-09-2013, 18:55
#11

The first parameter is not the direction but what to sort like id or date. For the direction there is another method.

Member
Member
sbillard   29-09-2013, 19:17
#12

You selected sorting by the desc field, I think you want to sort by the date field.

$_zp_current_search->setSortType('date','image');

As well, you have executed code that does the search (the bit about the number of images) before setting this direction, so things will already have been cached.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.