Problems, need help? Have a tip or advice? Post it here.
13 posts Page 1 of 2
okay so i want to have a option where you can seclude posts. This means that you can make posts in the future. I want a form that allows this, where you can then set the publish date with the databound form.

can this be done?
Oops! Thought I had the answer for you but I was wrong. Removed my post. In all of my attempts I was unable to affect the publish date using data-bound forms.

The variables themselves are k_month, k_day, k_year, k_hour, and k_min.
Hi,

The field you are looking for is 'k_publish_date' -
Code: Select all
<cms:if k_success >
    <cms:db_persist_form
        k_publish_date='2015-02-28'
    />

    ..
    ..

As with all dates (internally) in Couch, the format of the value is yyyy-mm-dd h:m:s

The following will unpublish the page -
Code: Select all
<cms:if k_success >
    <cms:db_persist_form
        k_publish_date='0000-00-00 00:00:00'
    />

    ..
    ..

Hope this helps.
Cool, I didn't know that one.

question: can we use it to modify the published date for the gallery page, thus modifying the order of the images?
Hi Paolo,

I think that should work for all kind of pages.
Hi KK,
I have a question about this. Don't know if I am missing something, or if I've just been working too long today!
I want to create/edit a calendar event using databound forms (accessed by an extended authenticated user on the front end).
My problem is that I can't figure out how to use the datepicker to change (or create) k_publish_date from a databound form.
I'm making a site for a hairdressers, and I don't have faith that they will be able to set the date in a text field like this - '2015-04-01' - so I want them to have a date picker on their "add booking" page/form. I just can't see how to do it at the moment...

Hope I've made sense!

Code: Select all
<cms:template title='Bookings' clonable='1'>
    <cms:editable name='desc' label='Notes' type='textarea' />
    <cms:editable
    name="staff_member"
    label="Which Staff member is the appointment for?"
    desc="Select one from these"
    opt_values='stafflist.php'
    dynamic='opt_values'
    type='dropdown'
/>

    <cms:editable name="start_time" label="Time From (24 Hrs)"
      opt_values='08:00 | 08:30 | 09:00 | 09:30 | 10:00 | 10:30 | 11:00 | 11:30 |
                  12:00 | 12:30 | 13:00 | 13:30 | 14:00 | 14:30 | 15:00 | 15:30 |
                  16:00 | 16:30 | 17:00 | 17:30 | 18:00 | 18:30 | 19:00 | 19:30 |
                  20:00 | 20:30 | 21:00'
      type='dropdown'
    />

</cms:template>


<cms:form
        masterpage='booking.php'
        mode='create'
        enctype="multipart/form-data"
        method='post'
        anchor='0'
        >

        Booking Name:<br />
        <cms:input name='k_page_title' type='bound' /><br />

        Notes:<br />
        <cms:input name='desc' type='bound' /><br />

        Staff Member:<br />
        <cms:input name='staff_member' type='bound' /><br />

        Date:<br />
        <cms:input name='k_publish_date' type='bound' /><br /> 

        Time:<br />
        <cms:input name='start_time' type='bound' /><br /> 
        <input type="submit" name="submit" value="Save"/>   

        </cms:form>
@ewanmc,

I think we can do that by not using the k_publish_date field directly in the form in a bound manner.
Rather, we'll use a 'datetime' field in the form e.g. like this -
Code: Select all
<cms:input
        name='my_datetime'
        type='datetime'
        default_time='@current'
        required='1'
/> 

and then push the value submitted through the datetime field above into the k_publish_date like this -
Code: Select all
<cms:if k_success >
    <cms:db_persist_form
        k_publish_date=frm_my_datetime
    />

    ..
    ..

You might also want to use the default CSS of datetime field to make it display properly on the front end -
Code: Select all
<link rel="stylesheet" href="<cms:show k_admin_link/>addons/data-bound-form/datetime.css?kver=<cms:show k_cms_build />" type="text/css" media="screen" />

Does this help?
That's great! I knew I was missing something - I'm pretty sure you demonstrated that previously in this thread - I just didn't grasp it!
I'll try it tomorrow (had enough coding for today), but that looks like the answer.
Thanks as always KK! :D
KK wrote: @ewanmc,

I think we can do that by not using the k_publish_date field directly in the form in a bound manner.
Rather, we'll use a 'datetime' field in the form e.g. like this -
Code: Select all
<cms:input
        name='my_datetime'
        type='datetime'
        default_time='@current'
        required='1'
/> 

and then push the value submitted through the datetime field above into the k_publish_date like this -
Code: Select all
<cms:if k_success >
    <cms:db_persist_form
        k_publish_date=frm_my_datetime
    />

    ..
    ..

You might also want to use the default CSS of datetime field to make it display properly on the front end -
Code: Select all
<link rel="stylesheet" href="<cms:show k_admin_link/>addons/data-bound-form/datetime.css?kver=<cms:show k_cms_build />" type="text/css" media="screen" />

Does this help?

Super solution for adding publish date from front-end, KK! My problem is that I should be able to edit the saved publish date also from the front-end, ideally using datepicker or if this isn't possible, other way. What do you think about this, is it possible?
Thank you.
My problem is that I should be able to edit the saved publish date also from the front-end, ideally using datepicker or if this isn't possible, other way. What do you think about this, is it possible?
Not a problem. Just set the default_time of the 'datetime' region to the publish_date of the page being edited and that would be it.

Sample code -
Code: Select all
<cms:set my_form_mode='edit' />

<cms:input
    name='my_datetime'
    type='datetime'
    default_time="<cms:if my_form_mode='edit' && k_page_date!='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else />@current</cms:if>"
    required='1'
/> 

In the code above we are setting the default_time to the page's publish date only if the page is being 'edited' (as opposed to being 'created') and is not in an 'unpublished' state.

In you happen to be using Couch v2.0, the documentation at viewtopic.php?f=5&t=10241 has a full-fledged example where we use a custom-field to mimic the system publish field. I suggest you take a look at how it works.

Hope it helps.
13 posts Page 1 of 2