Advance article page

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?

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:

  • Where is the date saved you want to filter by? Do you want to use a resource field (like the “Published On” field) or do you save the date in a TV?
  • Should users be able to select the “from” and “to” dates, or do you want to display a constant time span (like all resources published in the last 30 days)?
  • The “category” you want to filter by, is it a TV? Or do you use an extra like Tagger?
  • Do you use getResources or pdoResources to display the data? (There are subtle differences between these two snippets.)
  • I want to save the date on a TV so that the user can select the date.
  • Is this possible to make the category select-options?
  • I have no choice to use getResources or pdoResources, you can suggest me to use one of them.

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.