Member
Member
amucklow   2012-06-27, 11:36
#1

Hello

Is it possible to do something like this (using a custom GET() function)?

if (GET('sort')) { $sort = GET('sort'); setOption('gallery_sorttype', $sort, false); }
The GET() function is getting the key from the URL, and the option is updating on page refresh - this I can see via print_r(getOptionList());, BUT the order of the images doesn't change. Do I need to do something else, like clear memory?

Administrator
Administrator
acrylian   2012-06-27, 12:23
#2

Albums may have their own sortorder set which overrides the global one. So you need to set the album one directly. Some options cannot be set temparily and need to be really saved to work (last parameter to true). I am not sure right now if this is one of these. If the option is of course useless if you want users to change that.

Btw, you don't need a custom get funtion, the variable $_GET['sort'] is available if you append something to the url like &sort=. (That's php basics btw).

Member
Member
sbillard   2012-06-27, 15:59
#3

Sort order can also be overridden in the various function calls, for instance next_image().

Member
Member
amucklow   2012-06-28, 21:41
#4

Thanks - so just for others' benefit what I have now is:

`
if ($_GET['sort']) {
$sort = $_GET['sort'];
}

while (next_album(true, $sort)):

endwhile;
`

Member
Member
sbillard   2012-06-28, 22:07
#5

Just a small warning on this. If the sort passed is somehow not valid it may cause an error. Hackers often pass garbage strings to try to sus out a security hole. Something to think about.

Member
Member
amucklow   2012-07-03, 12:15
#6

OK - but I guess I could do a custom getSort() function that checked the sort against a list of pre-defined strings, 'name', 'id', 'date' etc.

Member
Member
sbillard   2012-07-03, 19:29
#7

Sounds like a good idea.

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