ZenphotoCMS Forum
news order in search page - 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: news order in search page (/thread-13019.html)



news order in search page - vincent3569 - 2017-09-28

hi

in search page, the news list is with title (or titlelink ?) order, but I want to list them with date (recent first) (as the default order in news loop on news page).
I have a look on next_news() paramaters, but there is no choice to do that.
In deprecated functions, I have the info that we have to set news order type and news order direction.

so I write this code in my search page:
`
[b][/b]

        `

but it has no effet on news order.
what is wrong ?




news order in search page - vincent3569 - 2017-09-28

btw, the markdown doesn't very well on my example.
I follow the rules of indentation, but it doesn't wwork on html code and I don't know what is wrong.




news order in search page - acrylian - 2017-09-28

Your code example looks fine formatted for me? Alternatively you can also use plain html for formatting as well.

Yes, you need to set the order via the search object. I can't say offhand but it might be already to late to set these values in that place. I have a far memory about an older forum post or something I can't find that you even might need to do this within the theme's functions.php. Have to try myself later today.

Also clear or disable the search cache just to be sure this doesn't interfere for unknown reasons.




news order in search page - fretzl - 2017-09-28

@vincent3569: FYI, I put your code between backticks to make it look a bit better.




news order in search page - vincent3569 - 2017-09-28

ok, I tested by adding this code in function.php:

if (in_context(ZP_SEARCH)) {
    $_zp_current_search->setSortType('date', 'news');
    $_zp_current_search->setSortDirection(0, 'news');
    $_zp_current_search->setSortType('title', 'pages');
    $_zp_current_search->setSortDirection(1, 'pages');
}

and it works fine for news order, but it doesn't work with pages (I tested with 'title' and 'date', but with no effect on sorte order).

btw: don't you think it could be a search parameter as it is the same one for album and image search order, set in admin>options>search?




news order in search page - acrylian - 2017-09-28

Have to try myself later when I get the time. It should work for any item type like this. Btw, instead of 0/1 better use true|false as actually meant (although it should come down to the same).

btw: don't you think it could be a search parameter as it is the same one for album and image search order, set in admin>options>search?

Yes, absolutely, default options for news and pages are actually on the list! Just didn't get to it




news order in search page - acrylian - 2017-09-28

It seems I can reproduce the issue with pages. Thanks for the ticket, would not have been necessary though.