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

Search

I know I can sort a data source from date to {$today} but how do I include time in this ?

Since you’ll be filtering your entries in day increments, you can look at sorting time on the XSLT end: xsl:sort.

I just thought it would be easier to use the ds.

Its for invoicing I need to keep track of the amount of entries and not double invoice for things, if I do to the day its no good it has to be to the second.

I also like having the pagination info, exact number of entries etc.

I have a $ds-from-date ‘2009-11-23 16:27:11’

Im currently filtering from {$ds-specific-carrier} to {$today}

You could try something like {$ds-specific-carrier} to {$today} {$current-time} although that will only get you down to the minute, not second.

If you’re happy enough to tweak your DS by hand, try doing the following.

Open up your DS and look at the filters array. It will be something like:

public $dsParamFILTERS = array(
    '1234' => '{$ds-specific-carrier} to {$today}',
    ...
);

Take notice of the field ID (above it is 1234).

Change/Add a __construct() function like so:

public function __construct(&$parent, $env=NULL, $process_params=true){
    $this->dsParamFILTERS['1234'] = '{$ds-specific-carrier} to ' . DateTimeObj::get('Y-m-d H:i:s');
    parent::__construct($parent, $env, $process_params);
    $this->_dependencies = array();
}

The important bit is the first line which injects the date into the filter before it is resolved.

Oh, if you edit your DS, make sure you remove the allowEditorToParse() function, or set it to return false. This will prevent your DS from getting overwritten via the DS editor.

Hey thanks for your help, its still not working however., would it be better to break the date and time apart and check separate?

    public $dsParamFILTERS = array(
            //'123' => '{$carrier-id}',
            //'130' => '',
    );


    public $dsParamINCLUDEDELEMENTS = array(
            'system:pagination',
            'name',
            'lead-date'
    );
    public function __construct(&$parent, $env=NULL, $process_params=true){
         $this->dsParamFILTERS['123'] = '{$carrier-id}';
         $this->dsParamFILTERS['130'] = '{$ds-specific-carrier} to ' . DateTimeObj::get('Y-n-d H:i:s');

         parent::__construct($parent, $env, $process_params);
         $this->_dependencies = array();
    }

something like this…

$this->dsParamFILTERS['130'] =  '{$ds-specific-carrier} to {$today} and ' . substr('{$ds-specific-carrier}', -8) . ' to ' . substr(DateTimeObj::get('Y-n-d H:i:s'), -8);

I’ve come back to this after all this time and am still having problems.

If this worked “later than {$ds-specific-carrier}” and included the time it would be perfect.

Right now that expression shows all the entries from the same day before and after the time in the $ds

{$ds-specific-carrier} is a date structured like “2010-04-19 17:58:00”

I ended up using nils’s date and time extension as it adds the ISO time to the data source where I can check to the second.

Does anybody know if (or how) this filter should work:

1971-01-01 00:00 to {$today} {$current-time}

(This has been proposed by Alistair, but the result doesn’t seem to take time into account.)

I think this has been raised in the past, that the Date field ignores times. Take a look at it’s buildRetrievalSQL method. From memory dates in the SQL are converted to YYYY-MM-DD. But this might have changed since I last tried.

It has been updated so that in 2.2, the Date field will respect the time.

Yes, it works in 2.2 beta! Nice to see that is has been implemented. (Clients kept asking me “how can I publish this article tomorrow at 09:00?”.)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details