Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
Hello,

I have worked with Trendoman in the past on this for another project using the Shopping cart addon, but can't figure out how to make this work.

I have clonable pages with the following field:

Code: Select all
         <cms:editable
        name='end_date'
        label='Date expiration'
        desc='Enter date in yyyy-mm-dd format e.g. 2012-12-31'
        type='text'
        validator='regex=/(?:19|20)\d\d-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|3[01])/'
        separator='#'
        validator_msg='regex=Incorrect date format'
        required='1'
        width='155'
    />


I need to make sure if we pass the date entered in that field, the actual page gets unpublished from the site.
Do I need a cron job or something like that to make this happen?

Basically I need:

If date in "end_date" field has passed, change status of current page to unpublished.
How can I make this possible? Thank you!
I found a way.

I have created a cron job file with the following code:

Code: Select all
<cms:pages masterpage='codes.php' custom_field="end_date < <cms:date format='Y-m-d' />">
<cms:if end_date>
<cms:db_persist
_masterpage=k_template_name
_mode='edit'
_page_id=k_page_id

k_publish_date='0000-00-00 00:00:00'
    />
</cms:if>
</cms:pages>


The Cron job will run once a day on the server. Seems to be working. Maybe not optimal, but works. Maybe this will help some people.
2 posts Page 1 of 1