I have a struct filter set up to display documents that have been reviewed
I was wondering if the Special columns" from here: https://www.dokuwiki.org/plugin:struct:aggregation#special_columns
can be used in a filter to check if reviewed date is before last updated
Here's my mark-up:
==== Documents updated since last review ====
The following documents have an //updated date// that is newer than the last //review date// so may need reviewing again.
---- struct table ----
schema: doc_data
cols: %title%, status, reviewed_date, %lastupdate%
filter: reviewed_date<%lastupdate%
----
This doesn't return any records.
I did think I could do this with a hidden schema field with a type of date or date/time and use prefilltoday property of that type but on further investigation I found that that it only populates the field if its empty.
So I turned to the code for the Value Placeholders (https://www.dokuwiki.org/plugin:struct:filters#value_placeholders) that I found in ./meta/SearchConfig.php
Using the developer information here (https://www.dokuwiki.org/devel:environment) I edited the file to add new FilterVars lines for
'$LASTMOD$'
and the associated values to return
$INFO['lastmod']
leaving the new code as:
protected function applyFilterVars($filter)
{
global $INPUT;
global $INFO;
if (!isset($INFO['id'])) {
$INFO['id'] = '';
}
// Code changed by CJ 2023-11-17 15:19:24 : added additional 2 options
// apply inexpensive filters first
$filter = str_replace(
[
'$ID$',
'$NS$',
'$PAGE$',
'$USER$',
'$TODAY$',
'$LASTMOD$'
],
[
$INFO['id'],
getNS($INFO['id']),
noNS($INFO['id']),
$INPUT->server->str('REMOTE_USER'),
date('Y-m-d'),
date('Y/m/d', $INFO['lastmod'])
],
$filter
);
This provides results now but the date comparison is not quite right
the filter is now
---- struct table ----
schema: doc_data
cols: %title%, status, reviewed_date, %lastupdate%
filter: reviewed_date < $LASTMOD$
----
$LASTMOD$
should be in the format Y/M/d to match the format of the reviewed_date field defined in the schema editor.
REviewed data in the schema is set to be in the past only. If reviewed date in the schema for a page is updated the $LASTMOD$
date is also updated so reviewed date will always be the same or older.
Because I'm using < in the comparison and not <= this should not return entries when the date parts of reviewed date and $LASTMOD$
are the same...
... BUT it does. Its returning all records.
Does anyone have any pointers as to what to try next?