Problems, need help? Have a tip or advice? Post it here.
14 posts Page 2 of 2
Apologies for the delay in my reply, guys.
I'm posting a little example that, I think, should help you in solving this issue.

Define a type 'datetime' editable region as follows -
Code: Select all
<cms:editable name='expiry_date' label='Expiry date' type='datetime' format='mdy'/>

The region above can be left empty if no expiry date applies to a page.
With that in place, we need to simply compare the expiry date set (if at all set) in the region with the current date like this -
Code: Select all
<cms:set current_date = "<cms:date format='Y-m-d H:i:s' />" />

<cms:if expiry_date && (current_date gt expiry_date) >
    <h1>page expired</h1>
<cms:else />
    <h1>ok</h1>
</cms:if>

I think you can adapt the code to suit your requirements.
Please let me know it helps.
Omg KK!

I read again my own reply after read yours. The answer lying there. I dunno if i can use gt with date :lol:

Its just out of my head :lol:

Ill try implement the code soon and post the result after i finish this office trip. Still accessing this forum throught smartphone anyway.

Still, thx KK for helping us.
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
On from this i've implemented the code, however i now want to use this code within the template of a product, so when a user buys a subscription it'll update within their profile.

So lets say the user registers on my website. The date is currently set at empty. Now lets say todays date is 30/11/2015. Now lets say the user buys a subscription from me of 4days.
the date would be 04/12/2015 The code bellow is something i've tired to work my head around with the same sorta idea of what i've been working on to update the amount from 10 to 9. However cant seam to work out how to implement this all.


Code: Select all
<cms:pages masterpage=k_member_template id=k_member_id >    
<cms:paypal_processor>
    <cms:if k_paypal_success>

        <cms:set current_date = "<cms:date format='Y-m-d H:i:s' />" />


<cms:db_persist  expiry_date && (set==d'4') />
   

    </cms:if>

    ..
</cms:paypal_processor>
</cms:pages>




Simon, the code to calculate the date four days from now would be -
Code: Select all
<cms:php>
    global $CTX;

    // calculate timestamp
    $ts_now = @strtotime('<cms:date format='Y-m-d H:i:s' />'); // current
    $ts_end = @strtotime("+4 day", $ts_now ); // current + 4
   
    // set the timestamp as a Couch variable (named 'my_stop_date')
    $CTX->set( 'my_stop_date', date('Y-m-d H:i:s', $ts_end), 'global' );
</cms:php>

The code above would set a global variable named 'my_stop_date' to hold that date.

You can now use it with cms:db_persist as follows -
Code: Select all
<cms:db_persist  
    ..
    ..
    expiry_date = my_stop_date
/>

Hope it helps.
14 posts Page 2 of 2
cron