Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I have set up an editable field:
Code: Select all
<cms:editable type='datetime' validator='MyDate::set_default_date'  name='item_date' format='dmy' default_time='@current' label="Published date" order='11' />
and have the following validator in kfunctions.php
Code: Select all
class MyDate{
    function set_default_date( $field ){
        global $FUNCS;
        $item_date = trim($field->get_data());
        // Set publish_date to value of this field
        $f = &$field->siblings[3];
        $publish_date = trim( $f->get_data() );
        if( $publish_date != '0000-00-00 00:00:00' ){
            $item_date = $FUNCS->make_date( $item_date );
            if( $publish_date != $item_date ){
                $f->store_posted_changes( $item_date );
        unset( $f );
        return true;

If I look at Publish date under 'Advanced settings' in the Admin Panel I can see the correct date i.e. it is the same as item_date. But when I do <cms:dump/> k_publish_date is empty (k_page_date reflects the date that is entered in to item_date).

I have tried
Code: Select all

        k_publish_date="<cms:show item_date />"

But that doesn't work either.

I'm assuming that it is important that k_publish_date is set up for sorting etc

Any suggestions?
If the k_page_date variable is reflecting the value you are looking for, that is all that needs to be done.
Don't worry about the 'k_publish_date' variable as seen in the dump.
ah - thanks for the speedy reply - I assumed I'd made a mistake somewhere!
3 posts Page 1 of 1

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 4 guests