[[+content_image]]
D
D
Dmitry Antonov2014-10-02 22:27:42
PHP
Dmitry Antonov, 2014-10-02 22:27:42

How to filter by date in modx?

The document is inferred via PdoPage

[[!pdoPage?
    &tpl=`tplServer`
    &parents=`7`
    &pageLimit=`5`
    &limit=`30`
    &includeTVs=`adress,date,hron,reit,sort`
    &tvFilters=`date==%[[!today]]%`
&showLog=`1`
]]
[[!+page.nav]]

tplServer Template
<tr>
    <td><a href="[[+tv.adress]]" target="_blank">[[+pagetitle]]</a></td>
    <td>[[+tv.reit]]</td>
    <td></td>
    <td>[[+tv.sort]]</td>
    <td>[[+tv.hron]]</td>
</tr>

Today snippet
return date("Y m d");
In general, what the current did not try to do with the tvFilters parameter, I still can’t display resources with the current date, and I’m also very interested in how to make a filter with the date "tomorrow".

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
D
Denis, 2014-10-10
@broder4ik

There are several solutions:
1) Try it in &where=`{"date":"[[today?]]"
2) And how is the TV date filled in? Myself? Why not filter by [[+publishedon]] - resource publication date or [[+createdon]] - creation date?

D
Dmitry Kulikov, 2016-06-17
@Dimaon

Through "where" filters on TV do not work.
Try changing the code in the today snippet to: return date('Y-m-d H:i:s');
And also remove the border of the snippet %%

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question