Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
I'm setting up an event calendar per the documentation provided online, but the small view is not linking correctly to a page view for events for the day:

Here's the code for the small calendar implementation from the index page:

Code: Select all
<div class="row">
         <div class="col-md-4">
         <div class="thumbnail text-center table-responsive">
         <cms:calendar masterpage='events.php'>
            <table id="calendarThumb" class="calendar_small table-bordered">
           <tr>
            <th colspan="7"><cms:date k_calendar_date format='F Y' /></th>
        </tr>
        <tr>
            <cms:repeat count='7'>
            <td class="months_heading"><cms:zebra 'Su' 'M' 'T' 'W' 'Th' 'F' 'S'/></td>
            </cms:repeat>
        </tr>

        <cms:weeks>
            <tr>
            <cms:days >
                <cms:if k_timeline_position='present'>
                    <cms:set tdclass='today' />
                <cms:else />
                    <cms:set tdclass='' />
                </cms:if>
               
                <cms:if k_position='current_month' >
                    <cms:if k_count_entries >
                         <td class='entries <cms:show tdclass />' >
                          <a href="<cms:link masterpage='events.php' year=k_year month=k_month day=k_day />"><cms:show k_day /></a>
                      </td>
                    <cms:else />
                        <td class='<cms:show tdclass />' ><cms:show k_day /></td>
                    </cms:if>
                <cms:else />
                    <td class='other_month'><cms:show k_day /></td>
                </cms:if>
            </cms:days>
            </tr>
        </cms:weeks>
            </table>
         </cms:calendar>
         <a href="events.php" class="btn btn-primary" role="button">See All Library Events</a>
         </div>
         </div>


And here's the full events.php code:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Events' clonable='1'>
    <cms:editable name='desc' label='Description' type='textarea' required='1' />
    <cms:editable name='location' label='Location' desc='Select the hosting branch'
      opt_values=' Library1 | Library2 | etc '
      type='dropdown' />

    <cms:editable name="start_time" label="Time From"
      opt_values=' Unspecified |
                  12:00am | 12:30am | 01:00am | 01:30am | 02:00am | 02:30am | 03:00am | 03:30am |
                  04:00am | 04:30am | 05:00am | 05:30am | 06:00am | 06:30am | 07:00am | 07:30am |
                  08:00am | 08:30am | 09:00am | 09:30am | 10:00am | 10:30am | 11:00am | 11:30am |
                  12:00pm | 12:30pm | 01:00pm | 01:30pm | 02:00pm | 02:30pm | 03:00pm | 03:30pm |
                  04:00pm | 04:30pm | 05:00pm | 05:30pm | 06:00pm | 06:30pm | 07:00pm | 07:30pm |
                  08:00pm | 08:30pm | 09:00pm | 09:30pm | 10:00pm | 10:30pm | 11:00pm | 11:30pm |'
      type='dropdown'
    />
   
    <cms:editable name="end_time" label="Time Until"
      opt_values=' Unspecified |
                  12:00am | 12:30am | 01:00am | 01:30am | 02:00am | 02:30am | 03:00am | 03:30am |
                  04:00am | 04:30am | 05:00am | 05:30am | 06:00am | 06:30am | 07:00am | 07:30am |
                  08:00am | 08:30am | 09:00am | 09:30am | 10:00am | 10:30am | 11:00am | 11:30am |
                  12:00pm | 12:30pm | 01:00pm | 01:30pm | 02:00pm | 02:30pm | 03:00pm | 03:30pm |
                  04:00pm | 04:30pm | 05:00pm | 05:30pm | 06:00pm | 06:30pm | 07:00pm | 07:30pm |
                  08:00pm | 08:30pm | 09:00pm | 09:30pm | 10:00pm | 10:30pm | 11:00pm | 11:30pm |'
      type='dropdown'
    />
   
   <cms:editable name='start_date' label='Event Date'
   desc='Enter date in yyyy-mm-dd formate e.g. 2010-12-31'
   type='text'
   validator='MyEvent::start_date'
   separator='#'
   validator_msg='MyEvent::start_date=Incorrect date format'
   required='1'
   />
   
   <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'
    />   
   
</cms:template>
<HTML>
<HEAD>
<cms:embed 'header.html' />

</HEAD>
<BODY>
   <div class="container-fluid">
   <cms:embed 'menu.html' />
    <cms:if k_is_page >
        <!-- Page View -->
      <b>Event:</b> <cms:show k_page_title /><br>
        <b>Description:</b> <cms:show desc /><br>
        <b>Location:</b> <cms:show location /><br>
        <b>Date:</b> <cms:date k_page_date format='F j, Y' /><br>
        <cms:if start_time!='Unspecified' >
            <b>From:</b> <cms:show start_time /><br>
        </cms:if>
        <cms:if "<cms:not_empty end_date />" >
            <b>End Date:</b> <cms:date end_date format='F j, Y' /><br>
        </cms:if>
        <cms:if end_time!='Unspecified' >
            <b>Till:</b> <cms:show end_time /><br>
        </cms:if>
       
    <cms:else />
        <!-- List view -->
        <cms:calendar date="<cms:gpc 'cal' />" masterpage=k_template_name show_future_entries='1' >
            <table class="calendar_big table-bordered">
                <tr>
                    <th><a href="<cms:concat k_page_link '?cal=' k_prev_calendar_date />"> << </a></th>
                    <th colspan="5"><cms:date k_calendar_date format='F Y' /></th>
                    <th><a href="<cms:concat k_page_link '?cal=' k_next_calendar_date />"> >> </a></th>
                </tr>
                <tr>
                    <cms:repeat count='7'>
                    <td class="months_heading"><cms:zebra 'Su' 'M' 'T' 'W' 'Th' 'F' 'S'/></td>
                    </cms:repeat>
                </tr>

                <cms:weeks>
                    <tr>
                    <cms:days >
                        <cms:if k_timeline_position='present'>
                            <cms:set tdclass='today' />
                        <cms:else />
                            <cms:set tdclass='' />
                        </cms:if>
                     
                        <cms:if k_position='current_month' >
                            <cms:if k_count_entries >
                                <td class='entries <cms:show tdclass />' align='center'>
                                    <a href="#"><cms:show k_day /></a>
                                    <ul>
                                    <cms:entries limit='2' skip_custom_fields='1'>
                                        <li>
                                            <a href="<cms:show k_page_link />"><cms:show k_page_title /></a>
                                        </li>
                                    </cms:entries>
                                    </ul>
                                </td>
                            <cms:else />
                                <td class='<cms:show tdclass />' ><cms:show k_day /></td>
                            </cms:if>
                        <cms:else />
                            <td class='other_month'><cms:show k_day /></td>
                        </cms:if>
                    </cms:days>
                    </tr>
                </cms:weeks>
            </table>
        </cms:calendar>
    </cms:if>
   </div>
</BODY>
</HTML>
<?php COUCH::invoke(); ?>
Hi,

The cms:link bit of code below will produce the 'archive-view' link -
<a href="<cms:link masterpage='events.php' year=k_year month=k_month day=k_day />"><cms:show k_day /></a>

For the page-view, I think we can simply use
<a href="<cms:show k_page_link />"><cms:show k_day /></a>

Does this help?
I'm trying to get a list of all the events for a given day - not in the calendar, but displayed as a page. I can get the individual events to display in a larger calendar view, but the small calendar - when a date with events is clicked, with the <cms:link masterpage='events.php' year=k_year month=k_month day=k_day /> in place - brings up the large calendar rather than an archive view.

Thanks,
Sam

ETA:

Here's the full code for the index page:

Code: Select all
<?php require_once ( 'couch/cms.php' ); ?>
<cms:template title='index'>
   <cms:repeatable name="gallery">
            <cms:editable type="image" name="work_picture" label="Photo" show_preview='1' preview_width='150' input_width='200' col_width='350' />
            <cms:editable type="text" name="picture_title" label="Picture Title"/>
            <cms:editable type="textarea" name="picture_description" label="Picture Description"/>
         <cms:editable type="text" name="picture_link" label="Link (Optional, include http://)" />
         <cms:editable type="text" name="button_text" label="Button Text (required if linked)" />
    </cms:repeatable>
</cms:template>
<!DOCTYPE HTML>
<html>
   <head>
      <cms:embed 'header.html' />
   </head>

<body>
   <div class="container-fluid">
      <cms:embed 'menu.html' />
      <div class="c-wrapper">
      <div id="mycarousel" class="carousel slide hidden-sm hidden-xs" data-ride="carousel">
            <div class="carousel-inner">
             <cms:show_repeatable 'gallery'>
             <cms:if k_count=='1'>
               <div class="item active">
             <cms:else />
               <div class="item">
              </cms:if>
                <img src="<cms:show work_picture/>" alt="">
                <div class="carousel-caption">
                  <h4><cms:show picture_title/></h4>
                  <p><cms:show picture_description/></p>
               <cms:if picture_link>
                  <a href="<cms:show picture_link />"><button class="btn btn-primary"><cms:show button_text /></button></a>
               </cms:if>
                </div>
              </div>
            </cms:show_repeatable>           
            </div>

      <!-- Controls -->
         <a class="left carousel-control" href="#mycarousel" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
         </a>
         <a class="right carousel-control" href="#mycarousel" role="button" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
         </a>
      </div> <!-- Carousel -->
      </div>
      </div>
      &nbsp;
      &nbsp;
      <div class="row">
         <div class="col-md-4">
         <div class="thumbnail text-center table-responsive">
         <cms:calendar masterpage='events.php'>
            <table id="calendarThumb" class="calendar_small table-bordered">
           <tr>
            <th colspan="7"><cms:date k_calendar_date format='F Y' /></th>
        </tr>
        <tr>
            <cms:repeat count='7'>
            <td class="months_heading"><cms:zebra 'Su' 'M' 'T' 'W' 'Th' 'F' 'S'/></td>
            </cms:repeat>
        </tr>

        <cms:weeks>
            <tr>
            <cms:days >
                <cms:if k_timeline_position='present'>
                    <cms:set tdclass='today' />
                <cms:else />
                    <cms:set tdclass='' />
                </cms:if>
               
                <cms:if k_position='current_month' >
                    <cms:if k_count_entries >
                         <td class='entries <cms:show tdclass />' >
                          <a href="<cms:link masterpage='events.php' year=k_year month=k_month day=k_day />"><cms:show k_day /></a>
                      </td>
                    <cms:else />
                        <td class='<cms:show tdclass />' ><cms:show k_day /></td>
                    </cms:if>
                <cms:else />
                    <td class='other_month'><cms:show k_day /></td>
                </cms:if>
            </cms:days>
            </tr>
        </cms:weeks>
            </table>
         </cms:calendar>
         <a href="events.php" class="btn btn-primary" role="button">See All Library Events</a>
         </div>
         </div>
         <div class="col-md-4">
         <div class="thumbnail text-center"><img id="cardReg" src="images/cardregistration.png"><a href="http://gapines.org/eg/opac/register" class="btn btn-primary" role="button">Click to Apply Online!</a></div>
         </div>
         <div class="col-md-4">
         <div class="thumbnail text-center"><img src="images/freedom-to-read-vote-200.png"><a href="https://registertovote.sos.ga.gov/GAOLVR/#no-back-button" class="btn btn-primary" role="button">Register to Vote</a></div>
         </div>
      </div>
   </div>
         
   
      

      
</body>         
</html>   
<?php COUCH::invoke(); ?>
In a further mystery, I did a <cms:dump /> on both the <table class="small_calendar"> view used in a sidebar, and on the events.php big_calendar view under the <cms:days> tag.

The events.php dump gives the following output for a day with events.

days
k_date: 2014-10-03
k_day: 3
k_month: 10
k_year: 2014
k_day_of_week: 5
k_position: current_month
k_count_entries: 2
k_timeline_position: future
tdclass:


The same day under the dump for the sidebar on the index.php -

days
k_date: 2014-10-03
k_day: 3
k_month: 10
k_year: 2014
k_day_of_week: 5
k_position: current_month
k_count_entries: 0
k_timeline_position: future
tdclass:
Alright, after reading through the documentation, here's where I am:

I've got the sidebar/small calendar view showing future events. I now have an archive view working (almost) how I want. It's showing all the events up to a certain date, rather than just the events for the date being selected.

Here's the code for the view:

Code: Select all
<html>
   <head>
      <cms:embed 'header.html' />
   </head>
   <body>
      <div class="container-fluid">
         <cms:embed 'menu.html' />
         <cms:archives masterpage=k_template_name type='daily' show_future_entries='1'>
            <cms:pages master=k_template_name order='desc' start_on=k_archive_date stop_before=k_next_archive_date show_future_entries='1'>
               <div class="panel panel-default">
                  <div class="panel-header">
                     <h2><cms:show k_page_title /></h2>
                  </div>
                  <div class="panel-body">
                     <b>Description:</b> <cms:show desc /><br>
                     <b>Location:</b> <cms:show location /><br>
                     <b>Date:</b> <cms:date k_page_date format='F j, Y' /><br>
                     <cms:if start_time!='Unspecified' >
                        <b>From:</b> <cms:show start_time /><br>
                     </cms:if>
                     <cms:if "<cms:not_empty end_date />" >
                        <b>End Date:</b> <cms:date end_date format='F j, Y' /><br>
                     </cms:if>
                     <cms:if end_time!='Unspecified' >
                        <b>Till:</b> <cms:show end_time /><br>
                     </cms:if>
                  </div>
               </div>
            </cms:pages>
         </cms:archives>
      </div>
   </body>
</html>


The archive link is being called in this section of the calendar:

Code: Select all
 <cms:if k_count_entries >
                                <td class='entries <cms:show tdclass />' align='center'>
                                    <a href="<cms:link masterpage='events.php' year=k_year month=k_month day=k_day />"><cms:show k_day /></a>
                                    <ul>
                                    <cms:entries limit='2' skip_custom_fields='1'>
                                        <li>
                                            <a href="<cms:show k_page_link />"><cms:show k_page_title /></a>
                                        </li>
                                    </cms:entries>
                                    </ul>
                                </td>
                            <cms:else />
                                <td class='<cms:show tdclass />' ><cms:show k_day /></td>
                            </cms:if>


How can I get only the events for the k_day linked to show when the archive link is clicked?
Alright, I've figured out a solution to my problem, but I'm not sure of the execution:

Is there a way to compare two dates and determine which is earlier? I've tried

Code: Select all
<cms:if "<cms:date k_archive_date format="Ymd" />" lt "<cms:date format="Ymd" />">


but it throws an error upon encountering the "lt".

I'm really loving Couch because of the level of customization I'm able have. It's sometimes maddening, but I'd rather have the option to be this specialized than have a cookie-cutter site. :D

Thanks,
Sam
Apologies @slink, I couldn't tend to your thread - had a very busy last few days.

OK, let us start from the small calendar view. The link that you have in there -
Code: Select all
<cms:link masterpage='events.php' year=k_year month=k_month day=k_day />
will output something like -
Code: Select all
http://www.yoursite,com/events.php?d=20141002

or the following if prettyURLS are on -
Code: Select all
http://www.yoursite,com/events/2014/10/02/

That link is the 'archive-view' (please see http://www.couchcms.com/docs/concepts/views.html if you need details).

Point is, clicking on the link will still load 'events.php' but you'll have to handle the archive-view yourself.

Since by default, your events.php is showing the bigger calendar, you can do the following -
Code: Select all
<cms:if k_is_archive>
   .. we'll put the code handling this archive-view here ..
<cms:else />
    .. your original code showing the bigger calender comes here ..
</cms:if>

Now we can list all the events that fall in that archive period-
Code: Select all
<cms:if k_is_archive>
    <cms:pages master=k_template_name order='desc' start_on=k_archive_date stop_before=k_next_archive_date show_future_entries='1'>
        <h2><cms:show k_page_title /></h2>
        .. show other variables here ..
    </cms:pages>
<cms:else />
    .. your original code showing the bigger calender comes here ..
</cms:if>

Hope this helps.
No problem! It was a good thing, actually, as I ended up arriving at the same solution you posted - working through the issue gave me a better understanding of the CMS overall. However, when I went back and added folders to the template, the entire page vanished.

I'm working on figuring that out, now. :)

Thanks,
Sam
Stupid error - I had subfolders with the same "name" value, which caused an error that didn't display.

I've learned a lot from this process. Thanks for all the help, and I'm now even more pleased with Couch!

Sam
11 posts Page 1 of 2