recurring events

lauren.fraser's Avatar

lauren.fraser

02 Dec, 2010 09:23 PM

I've created an assett factory for our events pages. We have several recurring events. I'd like for users to be able to enter the event on time and choose the day of the week the event occurs on. Then use that data to display the events on the proper dates.

For example - every week we have a CPR class on Monday from 9 - 12. So the user would enter the event once, set the start date as Jan 1, the end date as Dec 31, and the day of the week as Monday.

Has anyone successfully implemented something along these lines?

  1. 1 Posted by Penny on 03 Dec, 2010 06:19 PM

    Penny's Avatar

    I have done this before. It is kind of tedious in a looping sense.

    I gave the user a Recurring radio button option (Recurring/Single), Start and End Dates, How often it Recurred (Daily/Weekly), (in case Weekly was chosen) Days of the Week checkboxes for what day of the week it recurred on (b/c it could recur on more than one day).

    I then using Velocity looped through every day and for every day got all events that start date and end date were around the date, marked as recurring Daily, or marked as recurring Weekly that had the same Day of the Week as the date.

    I have included a screen shot of my fields.

  2. 2 Posted by lauren.fraser on 05 Dec, 2010 07:00 PM

    lauren.fraser's Avatar

    Penny,
    Thanks for this. I had the days of the week button, but not the recurring or how often options.

    Any change you could send me the velocity script you used?

  3. 3 Posted by lauren.fraser on 06 Dec, 2010 10:55 PM

    lauren.fraser's Avatar

    Penny,
    I'm looking at our current calendar and it looks like we have some events that recur on odd intervals (like on three weeks, off one week).

    Any thoughts on a way to let users choose a series of dates in the data definition? If I allowed multiples on the start and end date, would I be able to use a similar looping velocity script?

  4. 4 Posted by lauren.fraser on 07 Dec, 2010 12:26 AM

    lauren.fraser's Avatar

    Here is what I'm thinking now.

    I copied the data definition and changed the way users enter dates and start/end times.

    For the dates, I added a calendar and allowed multiples.
    For start time - I used a group of three drop down menus (Hour, Minute, AM/PM)
    For end time - I used a group of three drop down menus (Hour, Minute, AM/PM)

    Now I can use Velocity #if, #then statements to display the multiple days on the page.

    But I'm stumped for the "index" of events or the upcoming events page. I assume I could still loop through every day and get the events that start on that day for a daily view.

  5. 5 Posted by Penny on 07 Dec, 2010 08:13 PM

    Penny's Avatar

    Hey Lauren,

    I have attached the Velocity that goes with what I originally sent you. It utilizes an index block of my Event Content Type with Append Calling Page selected as well.

    It relies on your current page being named the month number (in two digit format, so January should be 01 not 1). It will then make a calendar grid for that month in the upcoming/current year.

    This script could be modified to also pull in the year if you wanted to make a folder for each month and year.

    I would generally stick with using the Cascade Calendar items rather than making my own because the value returned is actually a unix timestamp that seems to mean more in Java and Velocity. I would suggest maybe considering making a Group in your Data Definition, allow this to be multiple and then within that have a Start and End Date options. I have attached a screenshot of what I think you may be going for, it allows for users to add multiple start and end dates.

  6. 6 Posted by lauren.fraser on 07 Dec, 2010 09:47 PM

    lauren.fraser's Avatar

    Penny,
    Thanks for this. I'll take a look at it today.

  7. 7 Posted by lauren.fraser on 07 Dec, 2010 11:18 PM

    lauren.fraser's Avatar

    Penny,
    I'm a little confused on how to set up the folder/page structure. Is my description below along the right lines?

    I would create my events (page for each type of class. with recurrence set using multiple start/end dates as needed). I could hold all of these in the classes-events folder. For these, I could write a velocity script to display the class data (CPR, Dates, Times, Description, Fees, Location, Contact, etc).

    Then I would create the calendar folder that has 12 pages, 01 - 12. For these pages, would I use an index block of the class-events content type?

    On these pages, I would use the velocity format you attached and it would create a monthly calendar. The script would loop through the "entries" on this monthly calendar listing would link back to the class pages I've created.

    Perhaps you could send me a link to an existing site using a similar method, to help me wrap my head around it.

  8. 8 Posted by Penny on 08 Dec, 2010 03:42 PM

    Penny's Avatar

    Hey Lauren,

    What you describe above seems pretty accurate. Clarification though: for the calendar that I implemented, the calendar only went forward and did not keep a list of past events. I always had 12 months, but those 12 months were related to the current month or the future month. So my December was for 2010 but my November was for 2011. You can modify the script so that you keep your years and months and store your events per starting month. You will need to change the Velocity to pull the year from the path of your current page. In that case your folder structure would be like:

    • 2011
      • 01
      • 02

    I am including screen shots of how everything is currently setup with how the Velocity format that I sent you should work.

    I have included a screen shot of my block, my file structure, and the calendar display.

    I am sorry but I do not currently have a site live viewable outside our office.

  9. 9 Posted by lauren.fraser on 08 Dec, 2010 03:49 PM

    lauren.fraser's Avatar

    Penny, Thanks for these. It will be a big help.

  10. 10 Posted by lauren.fraser on 22 Dec, 2010 02:16 AM

    lauren.fraser's Avatar

    We used a small service pack to get our calendar up and running. I now have two related questions.

    1. Is there a way to link to the current month in the calendar? For example on our main Class/Events page we have a link that says “Visit the calendar” – is there a way to have that link to the current month without having to update the link every month.

    2. We'd like to add some navigation to our calendar pages. For example on each Month's page there would be an icon that would allow you to go to the previous or next month. A drop down menu where you could choose the month and year would also be a nice feature.

  11. 11 Posted by Penny on 22 Dec, 2010 03:04 PM

    Penny's Avatar

    I have attached a txt file with the corresponding Formats.

    1. Attach a current page block. The following Velocity will work if your folder structure is events -> yyyy -> mm. If not you may have to slightly modify the path and date formatting.

    2. The following should work for previous/next buttons assuming the folder structure events -> yyyy -> mm and that your month pages are in the correct folder order. This Format should be used in combination with an Index Block of your events folder, going two levels deep, rendering pages, xml does not need to be inline.

  12. 12 Posted by lauren.fraser on 22 Dec, 2010 03:25 PM

    lauren.fraser's Avatar

    Penny,
    A few quick questions.

    1. I already have a block attached to my default area, so I applied the current page block to my rightside bar area.

    I've attached the format, but it's not showing the link, just the text. If I look at the format, it looks like it's just setting the current date and month. What path do I need to use for the link?

    1. For the next/previous month buttons, do I need to add this to the existing format that displays our calendar pages in a table?

  13. 13 Posted by Penny on 22 Dec, 2010 03:41 PM

    Penny's Avatar
    1. Adjust the path before the ${currentMonth} part of the path. I think you may have calendar instead of events. $currentMonth should currently output 2010/12 so I think you need /calendar/2010/12.

    2. No, that format will use a different block than the one for the table. You will need to make additional region(s) for the provided formats.

  14. 14 Posted by lauren.fraser on 27 Dec, 2010 01:45 PM

    lauren.fraser's Avatar

    Penny,

    1 is working, it as the path.

    1. I created an additional region and applied the current-page block and attached the format from above. I'm not getting any errors, but I'm also no seeing any content. Not sure what I need to do different to get it to display correctly.
  15. 15 Posted by Penny on 27 Dec, 2010 02:50 PM

    Penny's Avatar

    Hey Lauren,

    The block that you will need to use for the second script will be an Index Block of the folder containing the calendar years. It will need to be set to a depth of two levels.

  16. 16 Posted by lauren.fraser on 28 Dec, 2010 04:44 PM

    lauren.fraser's Avatar

    Penny, That fixed it. Thanks for the quick reply.

    If I wanted to add drop down/jump menus, could I just add that code into the existing format?

  17. 17 Posted by Penny on 29 Dec, 2010 04:17 PM

    Penny's Avatar

    Hey Lauren,

    You could use the same block and format as the second format (the one that indexes your calendar folder).

    I would just be careful to make sure that there is no conflict with variables being used.

    The way I would approach this would be to write the html and possible javascript for the dropdown/menu that would work without using Cascade blocks or formats. You could then take that 2nd format and write the script necessary to generate the items in the dropdown in the html that you would have created previous.

  18. 18 Posted by lauren.fraser on 03 Jan, 2011 07:37 PM

    lauren.fraser's Avatar

    Penny,
    Thanks for the direction, it worked for me.

    Another request came up from our ed services department.
    They would like to display the next 3 dates for a particular class. I know that I can set the current date.

    Would there be a way to use the current date to "filter" the dates for each class and use a count to display the next three classes?

  19. 19 Posted by Penny on 06 Jan, 2011 08:47 PM

    Penny's Avatar

    Hey Lauren,

    Are you talking about on the actual Event? If so, this can be done but the logic for it isn't the simplest b/c you're going to need to make some logic to check if the current date has passed the event end date. Then you're going to need to check to make sure that you only output up until the end date and not past it, meaning you may only be able to output 2 even if you set it for outputting 3.

    The Daily ones will be much easier than the Weekly ones as well.

    If you are talking about only outputting events that are entered for specific dates (so not recurring), this would also be easier, you can set an if in the for loop with that limit.

    I hope this helps.

  20. lauren.fraser closed this discussion on 11 Jan, 2011 05:51 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac