Hi everyone,
I would like to display articles with:
- Timeframe (from date - to date) and category with checkbox
- When the timeframe has expired it will remove from the article page automatically
could anyone help me to achieve this?
Hi everyone,
I would like to display articles with:
could anyone help me to achieve this?
With getResources/pdoResources you can usually use the properties &where
and &tvFilters
to filter the data.
How exactly it would work in your case depends on a lot of factors:
Maybe take a look at this example (or search for similar ones in the forum).
Then adapt it to your needs.
Sure.
Using pdoResources should simplifies things when you deal with TVs.
How?
using tv or tagLister?
To my knowledge tagLister is just a bundle of some helper snippets. The data is still stored as a normal TV.
As you need to write a custom snippet anyway, to combine the date with the category filter, there is probably not much benefit from using tagLister (at least for the filtering part).
[[pdoResources?
&parents=`3`
&depth=`0`
&includeTVs=`article_type, expire_date`
&where=`{"expire_date:<=": "[[!date]]", "article_type:=": "Exhibition"}`
&tpl=`@CODE:<li><a href="[[+link]]">[[+pagetitle]]</a></li>`
]]
Now I am trying to exclude posts by the expire-date only, if the selected expiration date is less than the current data those posts will exclude. But this code is not excluding the posts.
Is this code correct?
And please solve one more thing if I have two TV to select starting date and ending date to exclude the posts then how to write the code?
Thanks in advance.
What is the code of this “date” snippet?
I thought, [[!date]] represents the current date.
How can I compare the current date the tv “expire_date”, so that it can be filtered?
Note: expire_date tv field allow to put the date only not time.
No! (All you get is an error message in the log “Could not find snippet with name date.”)
You could use the extra getDate or create a custom snippet.
https://extras.modx.com/package/getdate
You also have to format the current date correctly, so that is corresponds to the format of the TV in the database:
[[!getDate:date=`%Y-%m-%d %H:%M:%S`]]
Then maybe try [[!getDate:date=`%Y-%m-%d 00:00:00`]]
instead.