Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Currently I am working on a website for my brother who plays in a Pearl Jam tributeband.

I want to create an event list with an upcoming and a past list of gigs.

My template is a follows:

Code: Select all
<cms:template title='Gigs' clonable='1' dynamic_folders='1' order='4' >

  <cms:editable name='end_date'
      label='Event End Date (if multi-days event)'
      desc='Enter date in yyyy-mm-dd format e.g. 2010-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'
      width='155'
      order='1'
   />   
   
   <cms:editable name='datepicker' type='message' order='2'>
      <link rel="stylesheet" type="text/css" media="all" href="<cms:show k_couch_link />addons/datepicker/datepicker.css" />
      <script type="text/javascript" src="<cms:show k_couch_link />addons/datepicker/datepicker.js"></script>
      <script type="text/javascript">
         window.addEvent('domready',
            function(){
               $('f_end_date').addEvent('click', function(e){
               displayDatePicker('f_end_date');
               });
            }
         );
      </script>
   </cms:editable>

  <cms:editable
    name="start_time" label="Aanvang"
    opt_values=' Unspecified |
                00:00 | 00:30 | 01:00 | 01:30 | 02:00 | 02:30 | 03:00 | 03:30 |
                04:00 | 04:30 | 05:00 | 05:30 | 06:00 | 06:30 | 07:00 | 07:30 |
                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 | 21:30 | 22:00 | 22:30 | 23:00 | 23:30 |'
    type='dropdown'
    order='3'
  />
   
  <cms:editable
    name="end_time" label="Tot"
    opt_values=' Unspecified |
                00:00 | 00:30 | 01:00 | 01:30 | 02:00 | 02:30 | 03:00 | 03:30 |
                04:00 | 04:30 | 05:00 | 05:30 | 06:00 | 06:30 | 07:00 | 07:30 |
                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 | 21:30 | 22:00 | 22:30 | 23:00 | 23:30 |'
    type='dropdown'
    order='4'
  />

  <cms:editable name='location' label='Locatie' type='text' order='5' />

  <cms:editable
    name='info'
    label='Informatie'
    type='richtext'
    toolbar='basic'
    order='6'
  />
</cms:template>

I'm using the date picker to create the date:
viewtopic.php?f=8&t=7126

How can I create an upcoming and a past event list based on the 'end_date' of the 'Date Picker'?
Hi Martijn,

Could you please provide some more info as to what the exact requirements are?
Try pasting in some 'pseudo-code' of how you wish to list the events.

Thanks
I want a list of upcoming events and a list of events from the past.

My (unfinished) code is as follows:
Code: Select all
<cms:pages masterpage='gigs.php' show_future_entries='1' >
  <cms:date end_date format='%A %e %B %Y' locale='dutch' /> | <cms:show k_page_title /><br>
</cms:pages>

<div class="cfix"></div>

<h3>Past Gigs</h3>
<cms:archives masterpage='gigs.php' >
  <cms:date k_archive_date format='%A %e %B %Y' locale='dutch' /> | <cms:show k_page_title /><br>
</cms:archives>

I want something like above, but based on the 'end_date' of the 'Date Picker'.
Couch supports using the values within editable regions to control which pages get fetched by the cms:pages. The 'custom_field' parameter is the key here (an example of using custom dates to fetch pages can be found at viewtopic.php?p=9964#p9964).

The following snippet uses the value in 'end_date' to fetch pages that have this value greater or equal to the current date (effectively only future entries)
Code: Select all
<cms:pages masterpage='gigs.php' custom_field="end_date>=<cms:date format='Y-m-d' />" show_future_entries='1' >
  <cms:date end_date format='%A %e %B %Y' locale='dutch' /> | <cms:show k_page_title /><br>
</cms:pages>

Sadly, the second requirement that you have - creating 'archives', cannot be done using values of custom fields.

Hope this helps.
Thanks! That's exactly what I was looking for.

I was just testing the 'archives' tag. I had never used it before. But we can also use the pages tag to create the list of events from the past.

I ended up as follows:
Code: Select all
<cms:pages masterpage='gigs.php' custom_field="end_date>=<cms:date format='Y-m-d' />">            
  <cms:date end_date format='%A %e %B %Y' locale='dutch' /> | <cms:show k_page_title /><br>
</cms:pages>

<h3>Past Gigs</h3>
<cms:pages masterpage='gigs.php' custom_field="end_date<=<cms:date format='Y-m-d' />">
  <cms:date end_date format='%A %e %B %Y' locale='dutch' /> | <cms:show k_page_title /><br>
</cms:pages>
I am glad it worked :)

I'd just like to clarify a point here though -
the 'archives' tag actually does not produce a list of pages. It produces a list of 'time periods' (usually months) that have published pages within them (along with a count of these pages).

So, in fact, 'cms:archives' tag was not what would have done the job for you.
Using the cms:pages tag to list past pages is the right way.
You may want to change your conditions slightly, as you have some boundary overlap. When the 'end_date' equals the current date, you would have an event appear in both listings. I'm not sure what you would desire to happen in such a situation, but to rectify it you would remove the '=' from either '>=' or '<='.
You're right. I have removed the '='.

Thanks, cheesypoof! :)
8 posts Page 1 of 1
cron