Announcement

  •  » Engine
  •  » Filter out images in gallery view

#1 2016-08-13 04:52:26

Cynbel
Member
2016-07-27
8

Filter out images in gallery view

Hi,

So I'm doing a small amount of work where I need to filter out the images in the gallery view, but would like to get this to work on top of searches and the prev/next image when in detail view.

Basically I have a menu block where you can select a location to filter images by, it'll do a sql query to grab the images with only the selected location and currently if in an album it'll only show the images for that location. The problem is that this won't work if you do a keyword search or if in the detailed view of an image it won't filter the prev/next.  I need this filter to globally affect the gallery, but not sure if any event triggers would make this easier, or what the easiest way to go about doing this would be within a piwigo plugin.

The reason for this instead of using locations as keywords is that the keyword search doesn't maintain the album structure and the albums are organized by type and sub-types for items.

Offline

 

#2 2016-08-14 08:21:11

rvelices
Former Piwigo Team
2005-12-29
1960

Re: Filter out images in gallery view

There is a feature in piwigo: filters only recent photos. There is an icon in the menubar that does that and then it applies to everything.
The filtered data is saved in the session and is used by function get_sql_condition_FandF to get only images for which the user has permission and are not filtered.

Offline

 

#3 2016-08-16 00:07:36

Cynbel
Member
2016-07-27
8

Re: Filter out images in gallery view

So I assumed you meant I should utilize that in my code, i.e. adjust the $filter['visible_images'] which is used inside get_sql_condition_FandF, except nothing happened yet I know I was setting it, I even took a bit of code from the filter.inc file to set the session variable as well.

I thought this was odd so I threw in a few echos in get_sql_condition_FandF... it appears as though $filter['visible_images'] is always empty, but using the session variable seems to fix this.

Is it perhaps an error that the session variable isn't used inside get_sql_condition_FandF?

Also considering this changes the filter after it's been used by section_init, would it be better to use header("Refresh:0"); or for a 'loc_begin_section_init' trigger to be added?

Last edited by Cynbel (2016-08-16 00:49:42)

Offline

 

#4 2016-08-16 09:57:30

rvelices
Former Piwigo Team
2005-12-29
1960

Re: Filter out images in gallery view

Session variables are used for the default piwigo filter to build in memory $filter variable.
You could use your own session variables and fill from there the $filter variable.
You also have the 'init' event which is called on every piwigo page - you could fill the filter there ...

Offline

 

#5 2016-08-17 00:47:22

Cynbel
Member
2016-07-27
8

Re: Filter out images in gallery view

Turns out 'loc_end_section_init' was the one to use that way $page['items'] could be changed and keys rebased before it got used anywhere in the gallery, which also allowed the next/prev to filter correctly as well.

Thank you for pointing in the right direction on this.

Offline

 
  •  » Engine
  •  » Filter out images in gallery view

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact