ZenphotoCMS Forum
[1.4.5] Search sort order & pagelist navigation - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: [1.4.5] Search sort order & pagelist navigation (/thread-11178.html)



[1.4.5] Search sort order & pagelist navigation - Michel - 07-07-2013

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




[1.4.5] Search sort order & pagelist navigation - sbillard - 07-07-2013

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.




[1.4.5] Search sort order & pagelist navigation - sbillard - 07-07-2013

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.




[1.4.5] Search sort order & pagelist navigation - Michel - 28-09-2013

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




[1.4.5] Search sort order & pagelist navigation - sbillard - 29-09-2013

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.




[1.4.5] Search sort order & pagelist navigation - Michel - 29-09-2013

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




[1.4.5] Search sort order & pagelist navigation - acrylian - 29-09-2013

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




[1.4.5] Search sort order & pagelist navigation - Michel - 29-09-2013

Hi

The function does not work like this:
``

I'm confused right now :-)

TIA




[1.4.5] Search sort order & pagelist navigation - acrylian - 29-09-2013

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().




[1.4.5] Search sort order & pagelist navigation - Michel - 29-09-2013

Hi,

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

`

`
Still a no-go.

TIA




[1.4.5] Search sort order & pagelist navigation - acrylian - 29-09-2013

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




[1.4.5] Search sort order & pagelist navigation - sbillard - 29-09-2013

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.