Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I'd like to be able to limit the future entries of displaying pages not by hardcoding a certain date in the stop_before but by adding xx days/months to the cur_date.

Code: Select all
<cms:pages masterpage='agenda.php' limit='5' start_on=cur_date stop_before=cur_date+30days show_future_entries='1'>


By using the php function strtotime it's possible to use such notation but I don't know how to combine this with the couch cur_date.

Code: Select all
<?php
   $ts = strtotime("now");
   echo date('Y-m-d', $ts), '<br />';

   $tsDay = strtotime("30 day");
   echo date('Y-m-d', $tsDay), '<br />';

   $tsWeek = strtotime("+4 week");
   echo date('Y-m-d', $tsWeek), '<br />';
?>


How would this be possible?
Hi gizmo,

The code below demonstrates how we can use PHP to set a Couch variable.
Code: Select all
<cms:php>
    global $CTX;

    // calculate timestamp
    $tsDay = strtotime("30 day");
   
    // set the timestamp as a Couch variable (named 'my_stop_date')
    $CTX->set( 'my_stop_date', date('Y-m-d', $tsDay), 'global' );

</cms:php>

The variable we set above can now be used in the cms:pages tag e.g.
Code: Select all
<cms:pages masterpage='agenda.php' limit='5' start_on=cur_date stop_before=my_stop_date show_future_entries='1'>


Hope this helps.
Works out of the box ...as most of your solutions.

I had to add a bit of code to be able to show the events on the current date as well:

Code: Select all
<cms:php>
    global $CTX;

    // calculate timestamp
    $tsDay = strtotime("now");
    $tsDay2 = strtotime("+31 day");
   
    // set the timestamp as a Couch variable (named 'my_stop_date')
    $CTX->set( 'my_start_date', date('Y-m-d', $tsDay), 'global' );
    $CTX->set( 'my_stop_date', date('Y-m-d', $tsDay2), 'global' );
</cms:php>


Now the agenda works like it should. :D
Thanks for your help!
3 posts Page 1 of 1
cron