Hi all,
I changed the sort order on the searchpage by doing this:
`<?php while (next_image(false, NULL, 'date', 'desc')): ?>`
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
Comments
This would be a reasonable new feature. Maybe create an issue requesting it.
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.
I saw on github that you worked out this feature. Today I checked my website with `<?php while (next_image(false, NULL, 'date', 'desc')): ?>` 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
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.
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
The function does not work like this:
`<?php setSortType('desc','image');?>`
I'm confused right now :-)
TIA
Thnx for your explanation, at the beginning of my search.php i have this now:
`
<?php
zp_apply_filter('theme_body_open');
$total = getNumImages() + getNumAlbums();
if (!$total) {
$_zp_current_search->setSortType('desc','image');
}
?>
`
Still a no-go.
TIA
`$_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.