0 users online. Create an account or sign in to join them.Users

Search

Is there a way to escape the datasource filter operators like +? I would like to be able to use something like {$year}-{$month} +2 months (for the strtotime-function) in the datasource filter of a date/datetime field. At the moment I hacked the fields to urldecode the filter and I’m using %2B for the +.

I was also trying to accomplish something like this via datasource without success. I resorted to filter the data in xsl via date:add in exslt, so you could use something like:

select="date:add($today,'P2M')"

An alternative could be the Global Parameter Loader extension but I don’t know if it still works

Let me know if you find a better solution

Not sure about native syntax, but you could customise the DS. Leave your filter as {$year}-{$month} and inside grab() use something like:

$this->dsParamFILTERS['123'] = strtotime($this->dsParamFILTERS['123'] . '-01 +2 months');

Where 123 is the ID of the field you’re filtering on.

Jonas, I’m currently rebuilding the Date and Time field using Stage and I thought about adding new filter options so I would be interested in your thoughts. It should be easy to add the same rules to the default date field as well.

Thanks for the tips.

Giulio, filtering in the XSL is not an option because there will be many entries and I don’t want to get into memory problems.

Nick, I thought about something like that as well, but the filter actually is more complicated so changing the filter string is not so easy.

So I’m going to use my mentioned solution because it’s just a tiny hack and it allows me to everything I need. You just have to change

$where .= " AND DATE_FORMAT(`t$field_id".$this->key."`.value, '%Y-%m-%d') = '".DateTimeObj::get('Y-m-d', strtotime($date))."' ";

to

$where .= " AND DATE_FORMAT(`t$field_id".$this->key."`.value, '%Y-%m-%d') = '".DateTimeObj::get('Y-m-d', strtotime(urldecode($date)))."' ";

etc. in field.date.php respectively adjusted in field.datetime.php.

Nils, strtotimecan do a lot, so I’m happy when I can use all of its options. I’ll let you know when I stumble upon new ideas. What about a repeating date option in datetime field? ;-)

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