Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would like to filter based on date information stored with the page #688

Open
cjohnsonuk opened this issue Nov 17, 2023 · 0 comments
Open

Comments

@cjohnsonuk
Copy link

I have a struct filter set up to display documents that have been reviewed but then have been subsequently updated

Here's my markup

==== 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 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.
If reviewed date in the schema for a page the $LASTMOD$ date is also updated.

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. I tried looking through the

I did post the same in the forum. I'm hoping that this date functionality can be added like the very useful relative dates that were added in response to my request back in 2017 (thank you, by the way, that was much appreciated)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant