Search

Hi all,

I've never needed to use the special date filters in a datasource before, and I'm trying to achieve, essentially, 'none or later than $today'.

The field is an optional expiry field, so the idea is that if there's a date in the field, the entry should only be grabbed if the date is in the future.

I had a similar challenge. Since I didn't want to customize alle the datasources for the section, I solved it differently. I created an extension which sets a "far future" date (9999-12-31 00:00) if there is no field value. Of course, you have to hide this date from authors, which was pretty simple for me using XSLT because I use frontend forms for authors. In the Symphony backend I would probably hide the value using JavaScript.

If you are interested in some code for this solution, let me know, then I will try and find it.

Hi Michael,

Thanks for the response, and happy new year!

Interesting solution, however it's made me wonder if perhaps rather than having the expiry as optional, simply setting a default value for the field as a far-future date might work. So the default expiry could be 31/12/2050 for example. I don't mind not hiding it as it at least makes sense - however if there is a way to do 'empty or later than {$today}' I'm all ears - as I'd argue that's a little more intuitive. There are only ever going to be a handful of entries anyway, so it's not a problem that would come back to roost.

(I have a vague memory that I've asked about filtering by 'empty' before and not being able to get it to work)

I just gave this a try, and it's returning no results, it looks like it should work though, anything obviously wrong with it?

{$this-year:1979}-{$this-month:01}-{$this-day:01} to {$today}

I'm not actually using that date format, however $today in the param pool is in that format, so I'm not entirely sure how I should be handling the formatting in the filter…

Nathan, I believe this would be a time issue.

today is with a time of 00:00 so you will probably want to add "23:59" after the today variable. to include end of day maybe?

Ah, hadn't considered that - will experiment

Also I was being silly, that filter would essentially just get anything set to some point 'today'.

What I actually need to be doing is:

{$field-year:1979}-{$field-month:01}-{$field-day:01} 00:00 to {$today} 23:59

($field-day etc are made up variables, is there a way to target the components of the field like that? Or am I being far too hopeful?)

Edit: Gah, I don't think that'd make sense either, as a future date would end up being, for example '2016-08-02 to $today', I'm not entirely sure what that would return but it doesn't seem right.

I'm not sure if I'm over or under thinking it!

Edit 2: I'm clearly going mad (not a rare occurrence). The filter should actually just be 'empty or later than {$today}' like I mentioned in my OP, I got confused and forgot that somewhere along the lines. The more I think about it the more I don't think it's possible. There may be some fancy regex solution, but I've never clicked with regex.

Just a thought - is there any way to us a 'not' operator with DS filters?

not (earlier than {$today} ) would presumably return anything later and anything empty...

Good thinking Batman - I'm not sure how it'll parse the empty field with that logic, but in principle that's a really good idea and makes perfect sense! I need to wait until tomorrow to give it a shot, but I'll report back.

Thanks John!

It would be a good idea if it worked... sadly after a bit of forum-searching it seems it won't so it isn't!

By the sounds of things, the only negation possible is for a couple of specific fields as well as regex and sql(?).

Ah that's a shame.

It is a shame there's not more robust 'not' and/or 'empty' filters. Definitely something I'd like to see at some point.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details